Forum Discussion
Currency Conversion Data Model
Anonymous
Hi Neeko,
I tried a couple of other alternatives based on my above post.
So, I have an exchange rate table, that I do not want to attach to the fact or calendar date table yet.
My report has a requirement of a date slider and To Currency. The amount should be converted for that month in the date range slider such that - month 1, it will be sales amount * exchange rate for that month , added to next month 2, sales amount * exchange rate for that second month and so on.
In the attached file you will see, I created two Calculated Sales measures.
Calculated Sales -
I need to modify this query such that in the Calculate Function, I need to pick the correct Exchange Rate for that month, and not the MAX.
As you can see, for the date slider range, the Calculated Sales amount is picking up the max exchnage rate for November and calculating the amount based on this rate. This is not what I want. It should use the rate for the month that is provided.
In addition, I created another Calculated Sales 2 measure that creates a date table based on the date filter selected, and creates a start of month. (In this example, I used the first day of month in the fact table, but this is not the case, we have all dates).
I am unable to add the pbix file.
Let me know if this helps.
- Anonymous1 year agoNot applicable
Hi Rdarshana ,
1.Based on your description, I created a date table. You can then refer to the second reply to create a currency slicer table where you can modify the DAX code yourself to add your currency options.
Slicer = DATATABLE ( "Currency", STRING, { { "USD" }, { "MKD" } } )DATATABLE function - DAX | Microsoft Learn
2. Create measures.
Measure = var _select_currency=SELECTEDVALUE('Slicer'[Currency]) var _rate=CALCULATE(SUM('Exchnage Rate table'[Rate]),FILTER(ALL('Exchnage Rate table'),MONTH([Rate Date])=MONTH(MAX('Fact 1'[Date])) && [From Currency]=MAX('Fact 1'[Currency Code]))) var _amount=SUM('Fact 1'[Amount]) RETURN IF(_select_currency=MAX('Fact 1'[Currency Code]),_amount,_rate* _amount)To currency = IF(MAX('Fact 1'[Date]) in VALUES('CALENDAR'[Date]),SELECTEDVALUE('Slicer'[Currency]),BLANK())Please refer my pbix file.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.