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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
asmirnoffnorth
Frequent Visitor

FX Conversion: Directionality using IF statements

Hi all,

 

I hope everyone had a good New Year and are keeping safe. I am new to PowerBi and am slowly learning the ropes.

 

I was hoping someone could assist me in a nested IF statement to calculate a value. I have the following datatables:

 

FX: this stipulates the currency information and most importantly the direction of a certain currency (vs the USD)

 

IDNAMEINVERSE
1AUD1
2BRL0
3CAD0
4EUR1
5GBP1
6JPY0
7MXN0
8RUB0
9USD0

 

FXDATA: this hold the fx exchange rate data by different roots (sources) depending on the time of day

IDROOTIDFXIDVALUEDATE
1110.756930/12/2020
2-10010.7896530/12/2020
3125.268430/12/2020
4-10025.245330/12/2020
5131.28536430/12/2020
6-10031.2798730/12/2020
7141.2178530/12/2020
8-10041.208730/12/2020
9151.3568730/12/2020
10-10051.3679830/12/2020
1116103.6954830/12/2020
12-1006103.4236530/12/2020
131719.6430/12/2020
14-100720.4530/12/2020
151863.577430/12/2020
16-100864.23530/12/2020
1719130/12/2020
18-1009130/12/2020

 

SALES: this holds items and their local amounts.

IDDATEITEMAMOUNTFXID
130/12/2020item 1164,896,524.008
230/12/2020item 2203,857,678.008
330/12/2020item 368,078.978
430/12/2020item 430,980.421
530/12/2020item 57,594.525
630/12/2020item 691,115.507
730/12/2020item 795,427.764
830/12/2020item 812,661.953
930/12/2020item 917,211.146
1030/12/2020item 1059,489.099
1130/12/2020item 610,796.612
1230/12/2020item 971,384.185
1330/12/2020item 339,691.659
1430/12/2020item 686,725.455
1530/12/2020item 39,564.143
1630/12/2020item 888,367.646
1730/12/2020item 1097,405.524
1830/12/2020item 127,168.348
1930/12/2020item 343,512.213

On the Report view I use the following filters:

 

Sales.Date - self explanatory

FXDATA.RootID - tell the system which FX rate to use (given there are 2 values saved on a day per currency)

 

With those filters on, I want to calculate the USD amount for a certain Item (found in the SALES tab).

So essentially depending on the currency for that item, the system will look through the INVERSE column to figure out the direction of the calculation: if it is 0 then divide the local amount by the specific FX rate; if 1 multiply the local amount by the specific FX rate.

Changing the RootID filter should then yield a different result as the Report would use the (albeit slightly) different FX amount in its calculation. 

 

Expected Result

IDDATEITEMAMOUNTFXIDStep 1: What is FX rate for root ID and date selectedStep 2: FX direction inverse?Calculated USD amount   
130/12/2020item 1164,896,524.006103.423650                       1,594,379.27 Root ID-100
230/12/2020item 2203,857,678.006103.423650                       1,971,093.44 Date30/12/2020
330/12/2020item 368,078.97910                             68,078.97   
430/12/2020item 430,980.4210.789651                             24,463.69   
530/12/2020item 57,594.5251.367980                                5,551.63   
630/12/2020item 691,115.50720.450                                4,455.53   
730/12/2020item 795,427.7641.20870                             78,950.74   
830/12/2020item 812,661.9531.279870                                9,893.15   
930/12/2020item 917,211.146103.423650                                   166.41   
1030/12/2020item 1059,489.09910                             59,489.09   
1130/12/2020item 610,796.6125.24530                                2,058.34   
1230/12/2020item 971,384.1851.367980                             52,182.18   
1330/12/2020item 339,691.65864.2350                                   617.91   
1430/12/2020item 686,725.4541.20870                             71,751.01   
1530/12/2020item 39,564.14864.2350                                   148.89   
1630/12/2020item 888,367.646103.423650                                   854.42   
1730/12/2020item 1097,405.5241.20870                             80,587.01   
1830/12/2020item 127,168.34864.2350                                   422.95   
1930/12/2020item 343,512.2131.279870                             33,997.37   

 

 

If directionality wasn't an issue i would create a New Measure and use the SUM to take the value of the SALES.VALUE and / by SUM of the FXDATA.VALUE.

 

Any help will be greatly appreciated.

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@asmirnoffnorth see attached, in your post the output table you showed seems to be showing wrong data, anyhow check attached.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
asmirnoffnorth
Frequent Visitor

 Many thanks @jparr that has worked. i really do appreciate your prompt response!

parry2k
Super User
Super User

@asmirnoffnorth see attached, in your post the output table you showed seems to be showing wrong data, anyhow check attached.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.