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
Suryaann111
Frequent Visitor

Currency conversion-hierarchy date filter

Hi All,

I need some help in the logic.I have written a DAX query to calculate the exchange rate.

CALCULATE(MIN(T_CURRENCY[EXCHANGE_RATE]),FILTER(FILTER(T_CURRENCY,AND(AND(T_CURRENCY[FROM_CURRENCY]=MIN(T_SALES[FROM_CURRENCY]),T_CURRENCY[TO_CURRENCY]=FIRSTNONBLANK[T_CURRENCY(TO_CURRENCY],1)),

MIN(T_CALENDER[CALENDER_DATE]<=T_CURRENCY[EFF_END_DATE])),MIN(T_CALENDER[CALENDER_DATE]>=T_CURRENCY[EFF_START_DATE]);

 

T_CURRENCY TABLE

 

currency_ID From currency To_currency exchange rate EFF_START_DATE EFF_END_DATE
12 eur nok 4 6/1/2018 6/30/2018
12 eur nok 4 5/1/2018 5/31/2018
12 eur sek 6 6/1/2018 6/30/2018

 

slicers in the report:

to currency

calender date - hierarchy slicer.

The above DAX code will retrieve correct exchange rate only when a day is seleted in the date hierarchy slicer.

The problem here is when we select a year,say 2018,then the exchange rate should be picked from the latest month of 2018 available in the T_CURRENCY table.

if the to currency selected is nok ,and year selected is 2018,then exchange rate should be 4 (latest month of 2018 is 6).

 

Can someone help to incorporate this date logic in the above DAX.

 

Thanks in advance.

 

 

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Suryaann111 ,

 

We can try to use the following measure to meet your requirement:

 

Latest Exchange Rate =
CALCULATE (
    MIN ( T_CURRENCY[EXCHANGE_RATE] ),
    FILTER (
        ALLSELECTED ( T_CURRENCY ),
        T_CURRENCY[EFF_END_DATE] = CALCULATE ( MAX ( T_CURRENCY[EFF_END_DATE] ) )
    )
)

 

 


Best regards,

 

Community Support Team _ Dong Li
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

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @Suryaann111 ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lid-msft
Community Support
Community Support

Hi @Suryaann111 ,

 

We can try to use the following measure to meet your requirement:

 

Latest Exchange Rate =
CALCULATE (
    MIN ( T_CURRENCY[EXCHANGE_RATE] ),
    FILTER (
        ALLSELECTED ( T_CURRENCY ),
        T_CURRENCY[EFF_END_DATE] = CALCULATE ( MAX ( T_CURRENCY[EFF_END_DATE] ) )
    )
)

 

 


Best regards,

 

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

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.