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
Indiandotnet
Regular Visitor

Measures for un related table

111.png

 

I have two tables 

1. Exchanage Rate  (Contains Exchange rate of each quarter from Base currency USD)

2. Sales Detail  (Contains sales detail in Local currency and may contain dates which are not in the exchange  rate table)

Apart from this I have a Currency Dropdown on  page.

My challange is by changing the currency I need to show the sales amount in specific selected currency.

For which I have to pick exchanage rate according to sales date. Here the twist is sales date might be possible not present in Exchange Rate table. so in such situation i have to pick  latest exchange rate after sales date.

I appreciate your valuable inputs to create a measure.

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Indiandotnet ,

 

You may create measure like DAX below.

 

Matched Exchange Rate= MAXX(TOPN(1,FILTER('Exchange Rate Table', 'Exchange Rate Table'[Date]<=MAX('Sales Detail'[Sales Date])),'Exchange Rate Table'[Date], DESC),'Exchange Rate Table'[Exchange Rate])

Best Regards,

Amy

 

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

6 REPLIES 6
v-xicai
Community Support
Community Support

Hi  @Indiandotnet ,

 

Does that make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

v-xicai
Community Support
Community Support

Hi @Indiandotnet ,

 

You may create measure like DAX below.

 

Matched Exchange Rate= MAXX(TOPN(1,FILTER('Exchange Rate Table', 'Exchange Rate Table'[Date]<=MAX('Sales Detail'[Sales Date])),'Exchange Rate Table'[Date], DESC),'Exchange Rate Table'[Exchange Rate])

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Mariusz
Community Champion
Community Champion

Hi @Indiandotnet 

 

You can add the below as a column to yor Sales table and hide the Rate table 

Column = 
VAR _Currency = TREATAS( { Sales[Base Currency] }, Rate[Currency] ) 
VAR _SalesDate = Sales[Sales Date]
RETURN 
CALCULATE( 
    MAX( Rate[Exchange Rate] ),
    _Currency,
    Rate[Date] <= _SalesDate
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Actually I don't need calculated column. I need measure only because the value will change as per the selection of  currency dropdown.

Greg_Deckler
Super User
Super User

Perhaps something like:

 

Measure =
VAR __salesDate = MAX([Sales Date])
VAR __amount = MAX([Amount])
VAR __exchangeDate = MAXX(FILTER('Exchange Rates',[Exchang Rate] <= __salesDate),[Date]) // assumes exchange rate table filtered by slicer
RETURN
MAXX(FILTER('Exchange Rates',[Date] = __exchangeDate),[Exchange Rate])

Several assumptions made in there.


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

Thanks for the reply.

But it will not resolve the problem.

I need the exchange rate again each sales date. Now , the issue is there is no direct relationship between Exchange Rate table and Sales table. As Sales table may contain Dates which are not exists in Exchange Rate table.

Here is the logic

1. If Exchange Date of Exchange rate and sales date of sales table match then pic the exchange rate  of that particular row .

2. If exchange rate not exists for sales date then pic exchange rate of exchange date just below the sales date.

 

I hope it is more clear.

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.