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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
amit_saini
Master III
Master III

Convert Multiple Currency Sales to USD

Hi Folks,

Below is my data set:

Data Table:

   

IdCurrencyRateSales
a0C3100000hWz9cEACBRL3.1108$3,274,581.00
a0Ci0000006gMZrEAMCNY6.886$53,726,100.00
a0Ci000000NahCXEAZCNY6.886$155,849,641.00
a0Ci0000006hAWDEA2CNY6.886$36,332,593.00
a0C3100000j3KEhEAMEUR0.951022$6,159,000.00
a0C3100000j3KHREA2EUR0.951022$25,480,000.00
a0Ci000000NZ1v8EADGBP0.81367$3,696,902.00
a0C3100000j3PgQEAUGBP0.81367$5,804,945.00
a0Ci000000NZ1f0EADGBP0.81367$8,297,931.00
a0C3100000hWP9HEAWGBP0.81367$24,671,190.00
a0C3100000hWsBlEAKUSD1$1,555,166.00
a0Ci000000NaSSEEA3USD1$2,530,000.00

Exchange Rate Table:

 

CurrencyRate
BRL3.1108
CNY6.886
CNY6.886
CNY6.886
EUR0.951022
EUR0.951022
GBP0.81367
GBP0.81367
GBP0.81367
GBP0.81367
USD1
USD

1

I need to convert all sales to USD and present into final table.

At the moment I'm trying expression something like below:

if(Currency,'GBP',sum(Sales)/Rate,if(Currency,'BRL',sum(Sales)/Rate.....and so on.

But is there any best way of doing exchange rate conversion .

I need all sales figures in USD.

Thanks,

AS

1 Solution

Accepted Solutions
Kushal_Chawda

If you have link your data with exchange rate table based on currency then below expression should work

=sum(aggr(sum(Sales)/sum( distinct Rate), Currency, Month))

View solution in original post

5 Replies
niclaz79
Partner - Creator III
Partner - Creator III

Hi Amit,

Your sales already shows in $ in your table, but I am guessing this is the local currency right?

If your table are as above, just add the following line to your load script:

Sales * Rate as USDSales


The above will take the sales and multiply it by the rate of the same row, and your rows already contain both the rate and local currency sales number.

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Looks like you have the rates already in your data table. Why can't you simply divide Sales by Rate?


talk is cheap, supply exceeds demand
amit_saini
Master III
Master III
Author

Sorry Gysbert,

This is correct data:

   

IdCurrencySales
a0C3100000hWz9cEACBRL$3,274,581.00
a0Ci0000006gMZrEAMCNY$53,726,100.00
a0Ci000000NahCXEAZCNY$155,849,641.00
a0Ci0000006hAWDEA2CNY$36,332,593.00
a0C3100000j3KEhEAMEUR$6,159,000.00
a0C3100000j3KHREA2EUR$25,480,000.00
a0Ci000000NZ1v8EADGBP$3,696,902.00
a0C3100000j3PgQEAUGBP$5,804,945.00
a0Ci000000NZ1f0EADGBP$8,297,931.00
a0C3100000hWP9HEAWGBP$24,671,190.00
a0C3100000hWsBlEAKUSD$1,555,166.00
a0Ci000000NaSSEEA3USD$2,530,000.00

Rate is coming from other table.

Result need to be a bar chart with Month as Dim and Sale in USD as expression.

My problem is the when I'm doing exchange rate calculation for USD, some of the months are missing :

But if same USD in Million I'm calling in table as below you can see data for Mar and Apr , don't know what's the issue:

Thanks,

AS

Kushal_Chawda

If you have link your data with exchange rate table based on currency then below expression should work

=sum(aggr(sum(Sales)/sum( distinct Rate), Currency, Month))

niclaz79
Partner - Creator III
Partner - Creator III

Amit,

If you load the rate exchange table as a map, i.e

mCurrencyExchange:

Mapping LOAD distinct

    Currency,

    Rate

Resident ExchangeRateTable;

and then apply it to your currencytable with:

Sales * ApplyMap('mCurrencyExchange',Currency) as USDSales

You will get the same result. Be careful though if there are differenct exchange rates for different months etc you need to take that into consideration.

As for the months missing, there is not sufficient information on the app to know why that is.