Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dan80
Helper II
Helper II

FX Variance calculation - SUMX doesn't work

Hi all,

 

I need to conduct variance analysis on some financials including the impact of changes in fx rates.  The variance calculation is:

 

Actual Revenue_Base Currency - (Actual Revenue_Local Currency / Budget Fx Rate)

 

This is fine when there is only 2 currencies, however, in my data there is 10 different currencies and as a result the above calculation needs to be done at an individual row level and then 'summed up'.  To do this, I used SUMX e.g.

 

SUMX(Table, Actual Revenue_Base Currency) - (SUMX(Table, Actual Revenue_Local Currency) / (SUMX(Table, Budget Revenue_Local Currency)/SUMX(Table, Budget Revenue_Base Currency))

 

Results are correct at an individual currency level, however, the total is completey wrong as it appears that for the grand total is recalculating the variance as opposed to 'summing up' the individual parts.  A simple example is below, would appreciate any help.  Thanks,

 

Dan

 

VersionRegionTotal Sales Local CurrencyTotal Sales Base CurrencyFx RateFx Var 
BudgetUSA60010000.60  
BudgetEUR5009500.53  
ActualUSA4008000.50$133.33-$186.67
ActualEUR80012000.67-$320.00
       
Budget Summed110019500.56  
Actual Summed90017500.51$154.55 
7 REPLIES 7
Greg_Deckler
Community Champion
Community Champion

Are you doing this as a measure? If so, the Total line in a table can be not what is expected because the Total link calculates not upon what is in the table but rather looking at all of the data (essentially removes the row level context. Generally this is able to be fixed with some additional DAX work. Can you post some mock data and then your expected result?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for your reply and yes, I am trying to create a measure. The top 4 rows of the table in my original post is an example of the data, using these numbers I would expect the answer to be -$186.67 ie the sum of USA & EUR variances. Thanks

OK, thanks for explaining your data, I'll try to recreate. In the meantime, check out my DAX tip "Dealing with Measures" here:

 

http://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/m-p/63376#U63376

 

It focuses on this exact problem.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

OK, I think I am missing some pieces of this. It seems like you have some intermediary measures involved here like "Actual Revenue_Base Currency", etc. Can you post those formulas? And, I am assuming that the formula you posted is for Fx_Var, correct? Also, are you missing in ")" in the formula you posted?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi, sorry for the confusion, not easy to explain, the list of measures used are:

 

Actual Revenue Base Currency:=CALCULATE(SUMX(Table, Total Revenue Base Currency),Version="Actual")

Actual Revenue Local Currency:=CALCULATE(SUMX(Table, Total Revenue Local Currency),Version="Actual")

 

Budget Revenue Base Currency:=CALCULATE(SUMX(Table, Total Revenue Base Currency),Version="Budget")

Budget Revenue Local Currency:=CALCULATE(SUMX(Table, Total Revenue Local Currency),Version="Budget")

Budget Fx Rate:=DIVIDE([Budget Revenue Local Currency], [Budget Revenue Base Currency])

 

Then I reference the above in the variance calculation, as per:

 

Fx Variance:=[Actual Revenue Base Currency]-(DIVIDE([Actual Revenue Local Currency], [Budget Fx Rate]))

 

The example used stripped out other complications, such as month and product so I need the calculation to be completed at the lowest level and then 'Summed up'.  Really appreciate your help and time.  If you crack this I will buy you a beer 🙂

 

 

 

I'm apparently still missing some piece to this puzzle. I started with an Enter Data query of your data:

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcipNSU8tUdJRCg12BJJmBgZA0tAATBnomQFJpVgdJGWuoUFA0hQsb2kKUWVqDFPmmFxSmpgDN80ErMwCapgpkFQxNDbWMzZWQFUNMRSiztAIZrc5kNJVMTYy0AOKxMYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Version = _t, Region = _t, #"Total Sales Local Currency" = _t, #"Total Sales Base Currency" = _t, #"Fx Rate" = _t, #"Fx Var" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Version", type text}, {"Region", type text}, {"Total Sales Local Currency", Int64.Type}, {"Total Sales Base Currency", Int64.Type}, {"Fx Rate", type number}, {"Fx Var", type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Fx Rate", "Fx Var"})
in
    #"Removed Columns"

Basically:

 

 

VersionRegionTotal Sales Local CurrencyTotal Sales Base Currency

 

VersionRegionTotal Sales Local CurrencyTotal Sales Base Currency

BudgetUSA6001000
BudgetEUR500950
ActualUSA400800
ActualEUR8001200

 

Then I did your calculations as measures:

 

 

Actual Revenue Base Currency = CALCULATE(SUMX(Currencies, [Total Sales Base Currency]),Currencies[Version]="Actual")

Actual Revenue Local Currency = CALCULATE(SUMX(Currencies, [Total Sales Local Currency]),Currencies[Version]="Actual")

Budget Revenue Base Currency = CALCULATE(SUMX(Currencies, [Total Sales Base Currency]),Currencies[Version]="Budget")

Budget Revenue Local Currency = CALCULATE(SUMX(Currencies, [Total Sales Local Currency]),Currencies[Version]="Budget")

 

The only way I could come up with your numbers for Fx Rate was to use a Calculated Column:

 

Fx Rate = DIVIDE([Total Sales Local Currency],[Total Sales Base Currency])

 

Then I created a measure:

 

Fx Variance = [Actual Revenue Base Currency]-(DIVIDE([Actual Revenue Local Currency], SUM([Fx Rate])))

Now I put this into a Matrix with Version and Region and came up with:

 

variance.png

 

Which sort of looks right (other than totals obviously) but I don't feel like I arrived at your numbers the way you are doing it so I am obviously missing something. So before trying to get to the right answer, I want to know if this path looks correct or if I am still missing some piece of the puzzle.

 

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Ding Dong smoupre - thanks for taking so much time on this, appreciate it.  You are spot on re how my model is currenlty working, when I break it down to the most granular levels the variances are exactly the same as what you have, it is just that I need the totals to make sense as well.  Let me know if I can clarify anything else - thanks!

 

dan

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors