Jane.Yu Posted June 15, 2017 Share Posted June 15, 2017 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 value1,0,1,1,1,0,1,1,02. 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. Link to comment Share on other sites More sharing options...
dprogrammer Posted June 17, 2017 Share Posted June 17, 2017 something like this: create a variable that checks: {field}.contains("1)? 1 : 0create a running total and use that variable in it. then sum on the running total and it should give you total of 1's. Link to comment Share on other sites More sharing options...
Jane.Yu Posted June 19, 2017 Author Share Posted June 19, 2017 Thank you, Dprogrammer. It looks like contain function can be used to string datatype. My field is BigDecimal datatype. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now