contentengineer Posted May 8, 2007 Share Posted May 8, 2007 Need to convert a unique month identifier in a cross tab to a month name. Cannot use switch statement (not implemented in iR/Jasper). What expression do I use to create a 'monthname' parameter which is an array (for example "Jan","Feb","Mar,"Apr","May"... and then use this in a variable expression (where umid=unique month identifier since 1900) new String($P{monthname}.get($V{umid}.intValue())) ??? This fails (naturally!). Link to comment Share on other sites More sharing options...
contentengineer Posted May 8, 2007 Author Share Posted May 8, 2007 sorry to get month from 1...12 (Jan...Dec) i use following modulus: ($V{umid}%12+1) How do I define the vector/array parameter? How do I lookup the element of the array? Link to comment Share on other sites More sharing options...
contentengineer Posted May 8, 2007 Author Share Posted May 8, 2007 SOLVED. Used the following conversion routine: new java.lang.String(($V{umid}.intValue()/12+1900)+" "+("JanFebMarAprMayJunJulAugSepOctNovDec".toString().substring(($V{umid}.intValue()%12*3)).substring(0,3))) where umid=unique month since 1900 (i.e. Jan 2007=1284) Link to comment Share on other sites More sharing options...
chill_work Posted May 8, 2007 Share Posted May 8, 2007 I believe your solution is fine. Another way you might consider (if using a database source) is to add a table that has months and the unique identifier(is this unique identifier dynamic?). Now with your query, join to this table and do a group by for the identifier. I would then set one the fields to be the month and add the variable to my crosstab. I guess you are already grouping by the unique identifier and setting it as a field for the crosstab. Choices, choices :) 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