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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
stjernvd
Partner - Creator
Partner - Creator

Apply Exchange Rate to entire Dashboard

Hi,


I would like to apply an exchange rate to my entire dashboard so that when I click on the 'dollar' button, all my values change to dollars and vice versa for when I click on the 'GBP' button.

Dollar GBP.PNG

Here is my loaded data:

Script.PNG

So far I have created a variable called vCurrency and set it equal to 1 which works for activating the buttons. GBP=1 and Dollar =0 in Button/Actions/Set Variable/Value.

I have also created an exchange rate variable called vRate=0.63, since 1 dollar = 0.63 pounds.

How do I go about changing the exchange rate of my entire dashboard when clicking on each button? What should I enter into the script?

1 Solution

Accepted Solutions
sunny_talwar

If those are the only two currencies you are going to be dealing with, I suggest creating two fields in the script

LOAD Stock,

          Year,

          [No. of Shares],

          [Price per Dividend],

          Value as [Value in USD],

          Tax,

          Profit,

          Value * 0.63 as [Value in GBP] //Do the same for other fields like Tax, Profit and so on...

FROM ...

Now you can use your toggle button to toggle between dollar field and gbp field.

HTH

Best,

Sunny

View solution in original post

20 Replies
sunny_talwar

If those are the only two currencies you are going to be dealing with, I suggest creating two fields in the script

LOAD Stock,

          Year,

          [No. of Shares],

          [Price per Dividend],

          Value as [Value in USD],

          Tax,

          Profit,

          Value * 0.63 as [Value in GBP] //Do the same for other fields like Tax, Profit and so on...

FROM ...

Now you can use your toggle button to toggle between dollar field and gbp field.

HTH

Best,

Sunny

stjernvd
Partner - Creator
Partner - Creator
Author

Thank you!

Peter_Cammaert
Partner - Champion III
Partner - Champion III

If you want to do it using variables, change the 0.63 in Sunindia's code into $(vRate). The conversion rate that is applied to your data is now controlled by way of a variable, which is easier to patch than script code.

Also, in every expression that uses field Value in every object, change this field name into

[Value in $(vCurrency)]

Then modify your buttons so that vCurrency contains 'GBP' if the left one is selected, and 'USD' if the right one is selected. You can simply replace =0 by ='USD' and =1 by ='GBP'. You'll have to modify the color selection expression as well.

Peter

sunny_talwar

[Value in $(vCurrency)]

I really like this idea of yours and will probably use it in the application I work on.

Thanks Peter

Best,

Sunny

Peter_Cammaert
Partner - Champion III
Partner - Champion III

My pleasure.

stjernvd
Partner - Creator
Partner - Creator
Author

Hi Sunny,

I am trying to do the above calculations as a resident load and i keep getting error messages.


What's wrong with my script?

Resident Load.PNG

sunny_talwar

What is the error that you are getting? You can also try this:

Table1:

LOAD *,

          [Dollar Value] * 0.63 as [GBP Value],

          [Dollar Tax] * 0.63 as [GBP Tax],

          [Dollar Profit] * 0.63 as [GBP Profit];

LOAD Stock,

          Year,

          [No. of Shares],

          [Price per Dividend],

          Value as [Dollar Value],

          Tax as [Dollar Tax],

          Profit as [Dollar Profit]

FROM ...

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Eliminate the second load, but add the field calculations to the first load, like in:

LOAD Stock,

     Year,

     [No. of Shares],

     [Price per Dividend],

     Value as [Value in USD],

     Tax as [Tax in USD],

     Profit as [Profit in USD],

     Value * $(vRate) as [Value in GBP],

     Tax * $(vRate) as [Tax in GBP],

     Profit * $(vRate) as [Profit in GBP]

FROM ...

BTW please avoid posting screenshots as we are unable to copy your example code in our reponses...

Best,

Peter

stjernvd
Partner - Creator
Partner - Creator
Author

Hi Peter,

Thanks for this.

I am just wondering since I had already loaded the original table into my dashboard, why won't a resident table that I did above work to do the calculations for the exchange rate?

Danielle