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
Fro88er
Helper IV
Helper IV

Apply Exchange Rates to Local Currency button

I have request to add a simple Currency Button (Local/USD). When USD is selected it applies the respected currency rate.  I have built a Currency Table (disconnected). The Temp Revenue (selected currency) meaure works, however it is appying the CAD currency rate accross all of the regions not just Toronto. There is a currency ID on the Fact Table, call it USD and CAD or Currency ID, 1 and 2). Basicly, two field buttons [Local] no filter, [USD] apply currency rates.

 

Q: How to write this measure?

 

Temp Revenue (local) =
CALCULATE(
SUM('Fact1Staff Consolidated GP'[Temp Bill Amount]))
 
Temp Revenue (selected currency) =
SWITCH(TRUE(),
[Selected Currency]="CAD", [Temp Revenue (local)]*VALUES(DimCurrency[Currency Rate]),
[Temp Revenue (local)])
 
CurrencyToggleCurrency.JPGCurrencyToggleCAD.JPG
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Fro88er ,

Please update the formula of measure as below:

Temp Revenue (selected currency) = 
VAR _selcurrency =
    SELECTEDVALUE ( 'DimCurrency'[Currency] )
VAR _currate =
    CALCULATE (
        MAX ( 'DimCurrency'[Currency Rate] ),
        'DimCurrency'[Currency] = _selcurrency
    )
RETURN
    IF (
        _selcurrency = "CAD"
            && MAX ( 'Fact1Staff Consolidated GP'[Region] ) = "Toronto",
        [Temp Revenue (local)] * _currate,
        [Temp Revenue (local)]
    )

Apply Exchange Rates to Local Currency button.JPG

Best Regards

Rena

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @Fro88er ,

Please update the formula of measure as below:

Temp Revenue (selected currency) = 
VAR _selcurrency =
    SELECTEDVALUE ( 'DimCurrency'[Currency] )
VAR _currate =
    CALCULATE (
        MAX ( 'DimCurrency'[Currency Rate] ),
        'DimCurrency'[Currency] = _selcurrency
    )
RETURN
    IF (
        _selcurrency = "CAD"
            && MAX ( 'Fact1Staff Consolidated GP'[Region] ) = "Toronto",
        [Temp Revenue (local)] * _currate,
        [Temp Revenue (local)]
    )

Apply Exchange Rates to Local Currency button.JPG

Best Regards

Rena

Rena,

 

After closer examination the totals do not add up. Additionally, is there a solution that does not reference the Region and just let the CurrencyID drive the logic? The reason, I also have an By Office, By Practice, tables, plus if we add another CAD city/region I have to modify the code.

Yes, this worked perfectly! I will rename my buttons to better reflect what is going on!  Thank you so much, the timing could not be better! 

Greg_Deckler
Community Champion
Community Champion

@Fro88er - I had to read this through a few times. Sample data would have helped to make this clearer. However, if I understand correctly, you want to implement a currency conversion for non-US cities. If that is the case you could do this:

Temp Revenue (selected currency) =
  VAR __SelectedCurrency = [Selected Currency]
  VAR __CityCurrency = MAX('Fact1StaffConsolidatedGP'[CurrencyID])
  VAR __Rate = MAX('Currency Table'[Currency Rate])
RETURN
  IF(__SelectedCurrency = __CityCurrency,[Temp Revenue (local)]*__Rate,[Temp Revenue (local)])


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...

I am have the meaure working with the variable [Temp Revenue (selected currency)] but the total do not match.  When I write a seperate measure [Temp Revenue Test] the numbers and totals match. However, when I try and add/merge into only 1 measure, the [Temp Revenue (selected currency)] that includes the variables with a Sumx function the totals don't match either, what am I doing wrong?

 

Temp Revenue (selected currency) =
VAR __SelectedCurrency = 2
VAR __CityCurrency = MAX('Fact1Staff Consolidated GP'[ExchangeRateID])
VAR __Rate = MAX(DimCurrency[Currency Rate])
RETURN
IF(__SelectedCurrency = __CityCurrency,[Temp Revenue (local)]*__Rate,[Temp Revenue (local)])

 

Temp Revenue Test =
SUMX(
'Fact1Staff Consolidated GP',[Temp Revenue (selected currency)])

 

 

xTemp Revenue (Selected Currency)GD 2 =
VAR __SelectedCurrency = 2
VAR __CityCurrency = MAX('Fact1Staff Consolidated GP'[ExchangeRateID])
VAR __Rate = MAX(DimCurrency[Currency Rate])
Var VarTotal = IF(__SelectedCurrency = __CityCurrency,[Temp Revenue (local)]*__Rate,[Temp Revenue (local)])
Var VarTable = SUMMARIZE('Fact1Staff Consolidated GP','Fact1Staff Consolidated GP'[1Staff Office.Region],"RegionTempRevenue",VarTotal)
RETURN
SUMX(VarTable,VarTotal)
 
CurrencyToggleCurrency4.JPG

@Fro88er This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Sorry I lost track of this, I don't check my messages on this site very often!!



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...
lbendlin
Super User
Super User

Your SWITCH() statement needs to test for Toronto, not for CAD.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.