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
AliceW
Impactful Individual
Impactful Individual

How to select a conversion rate based on a date?

Hi everyone,

I hope one of you knowledgeable souls might have a solution for me.

I have two tables, Opps and ConversionRates. The Opps have the Amount column in a local currency, while ConversionRates has several rates for each Currency. I'd like to pick one of these currencies (they all convert to EUR) and bring it in the Opps table. It depends on the Opp Date column, as it needs to be between the rate start and end date

 

Opps:

Opp NumberDateCurrencyAmountRate 
11101/01/2020USD1001.7 
22230/06/2020BRL1004 

 

ConversionRates:

CurrencyRateStartEnd
USD1.501/01/201801/01/2019
USD1.702/01/201901/01/2023
BRL401/01/2017

31/12/2020

BRL501/01/2021

31/12/2022

 

It's going to be a many to many relationship, so just a RELATED won't work.. In the example above, the USD rate is 1.7 as the Opps.Date falls between the ConversionRates.Start and End in the second row.

Big thank you,

Alice

 

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

Hi @AliceW ,

 

Try this measure

Rate = 
CALCULATE (
    SUM ( 'ConversionRates'[Rate] ),
    FILTER (
        'ConversionRates',
        [Start] < MAX ( 'Opps'[Date] )
            && [End] > MAX ( 'Opps'[Date] )
            && [Currency] = MAX ( 'Opps'[Currency] )
    )
)

8.png

 

Tips: There's no relationship between two tables.

9.png

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
v-stephen-msft
Community Support
Community Support

Hi @AliceW ,

 

Try this measure

Rate = 
CALCULATE (
    SUM ( 'ConversionRates'[Rate] ),
    FILTER (
        'ConversionRates',
        [Start] < MAX ( 'Opps'[Date] )
            && [End] > MAX ( 'Opps'[Date] )
            && [Currency] = MAX ( 'Opps'[Currency] )
    )
)

8.png

 

Tips: There's no relationship between two tables.

9.png

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

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

Anonymous
Not applicable

Either you solve this in DAX where you lookup the conversion rate in the unrelated table ConversionRates 

 

Or you create a table where each date / currency comnination holds a value and the key is a concat of currency and date

eg

column 1                   column 2

USD 01/01/2018       1.5

USD 02/01/2018       1.5

..

USD 01/01/2019      1.5

USD 02/01/2019      1.7

 

Simular you create a key in the opps table and you can create a relationship between the keys

 

AliceW
Impactful Individual
Impactful Individual

Would you have a formula to help me look up the rate in DAX, please?

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.