Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Here is my loaded data:
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?
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
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
Thank you!
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
[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
My pleasure.
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?
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 ...
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
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