Case Statement in Jaspersoft Domain Calculated field?

Dear All,

I am trying to create a domain calculated field that has case statement, i am trying the below statement for the calculated field

case
when column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) between 0 and 0.35 then '0.25 Ton'
when column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) between 0.351 and 0.85 then '0.5 Ton'
when column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) between  between 0.851 and 1.35 then '1 Ton'
when column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) between  between 1.351 and 2.25 then '2.0 Tons'
when column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) between  > 2.25 then '2.5 Tons'
end

this query is working fine in oracle, but when i use this statement in calculated field it was showing as "Cannot evaluate expression"

Where i am making the mistake or how to make this above statement possible in Jaspersoft?

Kindly guide me...

Thanks in Advance,

Robert J

robert.j's picture
Joined: Oct 1 2013 - 6:13am
Last seen: 9 years 7 months ago

1 Answer:

Case statement is not supported in i-report

You can try this

column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) >= 0 && column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3))<=0.35 ? '0.25 Ton' :

column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) >= 0.351 && column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3))<= 0.85 ? '0.5 Ton' :

column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) >=  0.851 && column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3))<= 1.35 ? '1 Ton' :

column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) >=  between 1.351 && column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3)) <=2.25 ? '2.0 Tons' :

column1*Column2*Column3/1000000000*2.5*to_number(substr(Column4,2,3))   > 2.25? '2.5 Tons' : "Unknown"

 

Hope this help

hishamkmr's picture
808
Joined: Sep 4 2013 - 5:07am
Last seen: 9 years 1 month ago

Hi Hishamkmr,

I have tried with the above answer but i have encountered the following error "Found '&&' after end of expression"

Any other Suggestions...

Thanks in Advance,

Robert J

robert.j - 9 years 7 months ago

Hi Robert,
can you copy + paste the code you tried? is it the same code?

hishamkmr - 9 years 7 months ago

Hi Hishamkmr,
i have copy paste the same code and i have changed the column names and i have tried the error occurs and i have cleared the blank spaces and tried but the same result...

Any other views...

robert.j - 9 years 7 months ago
Feedback
randomness