Jump to content
We've recently updated our Privacy Statement, available here ×

Alternative to switch statement, lookup, arrays


Recommended Posts

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

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...