-3

I have a report which has two fields: amount and currency. The currency varies, (i.e USD, GBP etc.) I need to add a footer to each page with the total from each currency. eg :

Total in USD : 1200 | Total in GBP : 1890

There can be 100s of currencies. And I need to display each currency like the above in the footer of each page. There is no way to pre-determine the currency, therefore need to get the total in the Jasper Report itself.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Lahiru Tjay
  • 159
  • 2
  • 4
  • 14
  • could you please provide your dataset example or at least a sort of example of your complete report? maybe a link to a screenshot? – Fabio Fantoni May 11 '15 at 07:29

1 Answers1

1

Create a variable to add all currencies, use if clause to set currency to 0 where ever the value is null. Adding details as requested For Example create variable 1 Name: 'USD'
Class: java.math.BigDecimal
Calculation: SUM
Variable Expression: $F{Amount}*ExchangeRate
Similarly Create variable 2 'GBP' Now create a variable to display in footer
class: String
Variable Expression:

($V{USD}.equals('0')?null:"Total in USD :"+$V{USD})
+
($V{GBP}.equals('0')?null:"Total in GBP :"+$V{GBP})
Jonnny
  • 4,939
  • 11
  • 63
  • 93
Pu297
  • 151
  • 8