Forum Discussion
samerhaidar0811
3 years agoFrequent Visitor
Monthly Currency Exchange
Hi guys,
I hope you are having a great week.
Please consider the fact table below. It contains the cost and the currency in which the cost is displayed.
| Year | Month | Currency | Cost |
| 2022 | 1 | ZAR | 20000 |
| 2022 | 2 | ZAR | 20022 |
| 2022 | 3 | ZAR | 22000 |
| 2022 | 4 | ZAR | 30000 |
| 2022 | 1 | USD | 10203 |
| 2022 | 2 | USD | 34323 |
| 2022 | 3 | USD | 32453 |
| 2022 | 4 | USD | 46563 |
| 2022 | 1 | TRY | 50434 |
| 2022 | 2 | TRY | 43333 |
| 2022 | 3 | TRY | 43433 |
| 2022 | 4 | TRY | 54234 |
I also have a currency table containing the monthly and yearly currency exchange rates.
| Year | Month | Currency | to GBP |
| 2022 | 1 | ZAR | 22 |
| 2022 | 2 | ZAR | 23 |
| 2022 | 3 | ZAR | 23 |
| 2022 | 4 | ZAR | 25 |
| 2022 | 1 | USD | 12 |
| 2022 | 2 | USD | 12 |
| 2022 | 3 | USD | 13 |
| 2022 | 4 | USD | 14 |
| 2022 | 1 | TRY | 111 |
| 2022 | 2 | TRY | 123 |
| 2022 | 3 | TRY | 124 |
| 2022 | 4 | TRY | 124 |
I want to create a measure that would convert my cost column to cost in GBP (British Pounds) based on the exchange rates in the the currency table.
Any leads on how to do that?
My fault, I forgot to include the currency code in the lookup
Cost in GBP = VAR CurrentMonth = 'Table'[Month] VAR CurrentYear = 'Table'[Year] VAR CurrentCurrency = 'Table'[Currency] VAR ExchRate = LOOKUPVALUE ( 'Currency'[to GBP], 'Currency'[Year], CurrentYear, 'Currency'[Month], CurrentMonth, 'Currency'[Currency], CurrentCurrency ) RETURN 'Table'[Cost] * ExchRate
3 Replies
- johnt75
Super User
You could add a calculated column to the fact table like
Cost in GBP = VAR CurrentMonth = 'Table'[Month] VAR CurrentYear = 'Table'[Year] VAR ExchRate = LOOKUPVALUE ( 'Currency'[to GBP], 'Currency'[Year], CurrentYear, 'Currency'[Month], CurrentMonth ) RETURN 'Table'[Cost] * ExchRate- samerhaidar0811Frequent Visitor
Hi,
Im getting the below error when i create the column.
- johnt75
Super User
My fault, I forgot to include the currency code in the lookup
Cost in GBP = VAR CurrentMonth = 'Table'[Month] VAR CurrentYear = 'Table'[Year] VAR CurrentCurrency = 'Table'[Currency] VAR ExchRate = LOOKUPVALUE ( 'Currency'[to GBP], 'Currency'[Year], CurrentYear, 'Currency'[Month], CurrentMonth, 'Currency'[Currency], CurrentCurrency ) RETURN 'Table'[Cost] * ExchRate