Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
I wanted to run the data model currency conversion for the group out here.
This is what I have. The dimensions are all Dual Mode and Fact tables are Direct Query.
Exchange Rates are recorded at the first day of month and rate code
So, the Exchange Rate table is joined to the Calendar table on Rate Date == First Day of Month.
Exchnage Rate table is joined to both Fact 1 and Fact 2 on Currency Code.
What we need:
We will need to calculate the measures (Amount 1, Amount 2...) based on the currency code selected - In this case, it will be the To Currency in the exchange rate table.
My question - I am looking into DAX query calcs, and see that merges being suggested in forums.
I only want to levergae the calc based on the To Currency Code selected by the user.
Is there a cleaner way to do accomplish that>?
Hi @v-tangjie-msft ,
Thank you for helping with the DAX query.
However, that DAX query did not help me.
I am posting the query that worked for me, incase it helps someone.
Synopsis:
Financials Fact is joined to Calendar table, and data is stored at a daily level.
Exchange Rate table is not joined to any table in this data model. The rates are stored in a monthly level.
@v-tangjie-msft
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.
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.
Hi Neeko,
I looked at the DAX calc too, but there seems to be an issue with the model.
The relationship between Exchange Rate table and Fact 2 and Fact Table 1 tables is inactive as PBI identifies it as many-to-many relationship and presence of ambiguous relationships as Exchange rate table and Calendar tables are both joined to the fact tables.
So, let's say, we decide not to join the Exchange Rate table at all.
I am referencing this link - https://www.youtube.com/watch?v=HlR-AyzctLY
I can create a measure using LookUp function -
** I will have a currency slicer
** I have a calendar date slicer . The max date on this slicer should give me the first of month for that date.
and this first of month should give me the exchange rate
Measure =
The above DAX query works when I select the ToCurrency Code to be anything else other than USD.
If I select USD, then it gives me an error stating - "Couldnt load data for this visual. A table of multiple values was supplied where a single value was expected"
I added the IsBlank condition just to ensure that the data will show the original amount as is in the New amount field.
Is there anything amiss?
Hi @Rdarshana ,
According to your description, here are my steps you can follow as a solution.
(1) We can create a slicer table.
Slicer = DATATABLE (
"Currency", STRING,
{
{ "USD" },
{ "MKD" }
}
)
(2) We can create a measure.
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)
Measure 2 =
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 2'[Currency Code])))
var _amount=SUM('Fact 2'[Amount])
RETURN IF(_select_currency=MAX('Fact 2'[Currency Code]),_amount,_rate* _amount)
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
22 | |
17 | |
10 | |
9 | |
8 |
User | Count |
---|---|
40 | |
28 | |
18 | |
17 | |
15 |