daad.madhusudan Posted June 30, 2015 Share Posted June 30, 2015 I am working on a jasper report in that I am using a field "RACE_CODE" which contains values like 'abc','lmn','pqr','xyz'. For one person there can be multiple RACE_CODE assigned to it. So I want the output in term of four digits like: If a person have RACE_CODE 'abc' and 'xyz' then it should display '1001' and so on. I can use conditional statement like: $F{RACE_CODE} == 'abc' && $F{RACE_CODE} == 'xyz' ? '1001' : ($F{RACE_CODE} == 'abc' ? '1000' : so on But this is not a feasible way because for four digits I will be having 12 combinations. Is there any other way in which I can achieve this? Please help to solve this. Link to comment Share on other sites More sharing options...
sanbez Posted June 30, 2015 Share Posted June 30, 2015 $F{RACE_CODE} == 'abc' && $F{RACE_CODE} == 'xyz' always false. >>For one person there can be multiple RACE_CODE assigned to it.Report field have only one value.Question is unclear Link to comment Share on other sites More sharing options...
daad.madhusudan Posted July 1, 2015 Author Share Posted July 1, 2015 Thanks @sanbez for your response :).Yeah you are right. One person can have multiple race codes. In my case there are 7 race codes and one person can have many race codes from these seven values. So for this, I want seven digit binary representation. Want i want is:IF RACE_CODE CONTAINS (abc,lmn)then display 1100000if RACE_CODE CONTAINS (abc,xyz)display 1000001I am taking some test values here like abc,lmn,xyz for demo. Link to comment Share on other sites More sharing options...
Solution sanbez Posted July 1, 2015 Solution Share Posted July 1, 2015 Why 7 digids? You start only with 4 :) I guess that one of the possible values of $F{RACE_CODE} is "abcxyz" (you don't write example of data). Is it right? In this case you can use expression like this (java code example): public static void main(String[] args) { String RACE_CODE = "abcxyz"; System.out.println(RACE_CODE.indexOf("abc") == -1 ? "0" : "1" + (RACE_CODE.indexOf("lmn") == -1 ? "0" : "1") + (RACE_CODE.indexOf("pqr") == -1 ? "0" : "1") + (RACE_CODE.indexOf("xyz") == -1 ? "0" : "1")); }[/code] 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