how to convert decimal to string in a calculated field


There is a field (decimal datatype from hive) with value like: 101110110 (only 0 and 1 in every digit).

1. I would like to create calculated fields in ad hoc views and extract every position from this value


2. I would like to get the count of '1' from this hive field, so the count is 6 for this example.

I tried to use java function String.valueof(), replace() in the calculated field, and it failed the validation.

There are no function to convert decimal to string or replace strings in Jasper report server for adhoc view calculated fields.

We can't change the datatype to string in hive. How can I create these calculated fields? Please help. Thank you.


Jane.Yu's picture
Joined: Jun 30 2016 - 2:11pm
Last seen: 3 days 48 min ago

something like this: 

create a variable that checks: {field}.contains("1)? 1 : 0

create a running total and use that variable in it. then sum on the running total and it should give you total of 1's. 



dprogrammer - 2 months 4 days ago

Thank you, Dprogrammer. It looks like contain function can be used to string datatype. My field is BigDecimal datatype.

Jane.Yu - 2 months 2 days ago

0 Answers:

No answers yet