Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Good Morning,
I have a DAX to convert my costs from local currency to EUR. This conversion should depend on the period, year and scenaripo selected using filters.
This DAX (test) is the results of 2 DAX:
I would like the conversion to move according to the year, the scenario and the Month. We should be able to filter on Any brands in any country
My problem is that the total of my "Test" is not correct. It seems tricky to calculate a sum of measure being the results of 2 DAX already.
I tried to create a bridge table but this is not working
Solved! Go to Solution.
Hi @emiliePowerBI -Here SUMX calculates row-by-row results in ACTYTDEUR, but the total doesn't correctly aggregate these individual conversions.
FX Rate calculation with necessary filters into account
FX Rate =
CALCULATE (
AVERAGE('FX Table'[FX Rate]),
FILTER(
'FX Table',
'FX Table'[Date] <= MAX(Dates[Date]) &&
'FX Table'[Date] >= STARTOFMONTH(Dates[Date]) &&
'FX Table'[Scenario] = SELECTEDVALUE('ABC Master'[Scenario]) &&
'FX Table'[Country code] = SELECTEDVALUE('ABC Master'[Country code]) &&
'FX Table'[Brand] = SELECTEDVALUE('ABC Master'[Brands])
)
)
Use a measure for the row-level conversion, making sure it respects the filter context
Converted Cost Row-Level =
DIVIDE([ACTYTD], [FX Rate])
we want to sum up each row’s conversion without directly summing the results of [Converted Cost Row-Level] to avoid incorrect totals
ACTYTDEUR =
IF(
HASONEVALUE('ABC Master'[Country code]) &&
HASONEVALUE('ABC Master'[Brands]) &&
HASONEVALUE('Dates'[Month]) &&
HASONEVALUE('Dates'[Year]),
-- Row-level calculation
[Converted Cost Row-Level],
-- Total calculation
CALCULATE(
SUMX(
'ABC Master',
[ACTYTD] / [FX Rate]
)
)
)
check and apply the above logic and let me know if any
Proud to be a Super User! | |
Thanks a lot for your quick answer!
Your DAX measure test works well at the row level but not at the total level. This is a common issue when dealing with measures that involve division or other operations that don’t aggregate linearly.
One approach to solve this issue is to use SUMX to iterate over each row and then sum the results. This ensures that the calculation is done at the row level before summing up.
Try revising your test measure(For bridge table meaning evaluating against country code from bridge):
Test = SUMX('Bridge', [ACTYTD] / [FX Rate])
Ensure that the relationships between your tables are correctly set up.
Hope this helps!!
If this solved your problem, please accept it as a solution and a kudos!!
Best Regards,
Shahariar Hafiz
Hi @emiliePowerBI -Here SUMX calculates row-by-row results in ACTYTDEUR, but the total doesn't correctly aggregate these individual conversions.
FX Rate calculation with necessary filters into account
FX Rate =
CALCULATE (
AVERAGE('FX Table'[FX Rate]),
FILTER(
'FX Table',
'FX Table'[Date] <= MAX(Dates[Date]) &&
'FX Table'[Date] >= STARTOFMONTH(Dates[Date]) &&
'FX Table'[Scenario] = SELECTEDVALUE('ABC Master'[Scenario]) &&
'FX Table'[Country code] = SELECTEDVALUE('ABC Master'[Country code]) &&
'FX Table'[Brand] = SELECTEDVALUE('ABC Master'[Brands])
)
)
Use a measure for the row-level conversion, making sure it respects the filter context
Converted Cost Row-Level =
DIVIDE([ACTYTD], [FX Rate])
we want to sum up each row’s conversion without directly summing the results of [Converted Cost Row-Level] to avoid incorrect totals
ACTYTDEUR =
IF(
HASONEVALUE('ABC Master'[Country code]) &&
HASONEVALUE('ABC Master'[Brands]) &&
HASONEVALUE('Dates'[Month]) &&
HASONEVALUE('Dates'[Year]),
-- Row-level calculation
[Converted Cost Row-Level],
-- Total calculation
CALCULATE(
SUMX(
'ABC Master',
[ACTYTD] / [FX Rate]
)
)
)
check and apply the above logic and let me know if any
Proud to be a Super User! | |
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
92 | |
83 | |
71 | |
49 |
User | Count |
---|---|
143 | |
120 | |
110 | |
60 | |
57 |