Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Subtotal in a pivot table + AGGR or TOTAL

In a pivot table, I have sales data by country for different years. As sales are in local currency, they are multiplied by the exchange rate for the relevant country for sales in Euros.

The problem is with the subtotal in Euros when there are several countries with different currencies. If one country is selected, or countries which use the same currency, there is no problem.

Here is the expression which as the problem in the subtotal:

if(Dimensionality()=1 and SecondaryDimensionality()=1,

       sum(Sales)*[exchange rate],

       if(Dimensionality()=0 and SecondaryDimensionality()=1,

             sum(total <Period, Market> Sales)*[exchange rate]

       )

)

I have tried using AGGR and TOTAL, but couldnt get the right combination.

PFA the application.

Thanks a lot in advance!

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

It doesn't have to do with the currency being different but with the way you have your data model. Your expression:

sum(Sales)*[exchange rate]


sums all the Sales first, then multiplies by exchange rate. But your data model has an exchange rate for each record. So therefore you want to multiple the 2 first, then sum that. So I changed it to:


sum(Sales*[exchange rate])


The totals are now showing as expected.


Hope this helps!

View solution in original post

2 Replies
jerem1234
Specialist II
Specialist II

It doesn't have to do with the currency being different but with the way you have your data model. Your expression:

sum(Sales)*[exchange rate]


sums all the Sales first, then multiplies by exchange rate. But your data model has an exchange rate for each record. So therefore you want to multiple the 2 first, then sum that. So I changed it to:


sum(Sales*[exchange rate])


The totals are now showing as expected.


Hope this helps!

Not applicable
Author

Wow Jerem!

Yes it was as simple as that!!

Thanks a lot!