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
Anonymous
Not applicable

Issue with calculating revenue because of exchange rates

Hi,

 

I am having an issue with finding the revenue, because some rows are not populated with the exchange rate number (because it is only entered on random dates).

 

So I have a long list of orders in Query 1(in US dollars) and Query 2 has exchange rates (to convert to CAD).

 

Query 1 looks like this:

17.PNG

 

And Query 2 looks like this. It has exchange rates and the random dates they were entered into the system.

18.PNG

 

For example, the first exchange rate listed (1.223) applies to all dates between 10/1/2019 and 11/6/2020, so until a new exchange rate is entered in the system.

 

I am trying to calculate revenue  (Revenue = Unit Price * Quantity * Exchange Rate) but since there is not an exchange rate for every day, only the day that the number was entered, I am having difficulties.

 

Thank you!

 

2 ACCEPTED SOLUTIONS
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Kindly check below results:

04.PNG

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

Hi @Anonymous 

 

Use the below measures:

Measure 2 = IF(ISBLANK(MINX(FILTER(ALL(Table_4),[Date]>MAX(Table_4[Date])),[Date])),DATE(9999,12,31),MINX(FILTER(ALL(Table_4),[Date]>MAX(Table_4[Date])),[Date]))
Measure 3 = MINX(FILTER('Table_4',MAX(Table_3[Date])>=[Date]&&MAX(Table_3[Date])<[Measure 2]),[Exchange Rate])
Revenue1 = MAX(Table_3[Quantity])*MAX(Table_3[UnitPrice])*[Measure 3]

07.PNG

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

View solution in original post

4 REPLIES 4
v-diye-msft
Community Support
Community Support

Hi @Anonymous 

 

Kindly check below results:

04.PNG

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Anonymous
Not applicable

@v-diye-msft 

 

Is there any way to do this in direct query?

 

Currently, I can not use MINX, EARLIER, or FILTER in the column.

 

Hi @Anonymous 

 

Use the below measures:

Measure 2 = IF(ISBLANK(MINX(FILTER(ALL(Table_4),[Date]>MAX(Table_4[Date])),[Date])),DATE(9999,12,31),MINX(FILTER(ALL(Table_4),[Date]>MAX(Table_4[Date])),[Date]))
Measure 3 = MINX(FILTER('Table_4',MAX(Table_3[Date])>=[Date]&&MAX(Table_3[Date])<[Measure 2]),[Exchange Rate])
Revenue1 = MAX(Table_3[Quantity])*MAX(Table_3[UnitPrice])*[Measure 3]

07.PNG

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
Greg_Deckler
Super User
Super User

@Anonymous - Seems like you will need to create a measure to return the maximum date for the exchange rate that is less than the current date in your row. You can do this with MAXX using the correct FILTER. You could then use that to again use MAXX and FILTER to lookup the corresponding exchange rate. See this pattern:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.