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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
krzysztof
Helper III
Helper III

Last exchange rate

I have a problem with dax in Power Query:
Where null is empty, the new column finds the last course after the date assigned to the corresponding column
The expected effect is the "target column"

1.png

PBIX: https://drive.google.com/file/d/1Ywet6f7_poEBmynvGySCMHplnNo3lifV/view?usp=sharing 

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

Hi @krzysztof ,

You can create a calculated column as below to get it, please find the details in the attachment.

Target Column = 
VAR _date = 'Tabela'[Date]
VAR _currency = 'Tabela'[Currency]
VAR _predate =
    CALCULATE (
        MAX ( 'Tabela'[Date] ),
        FILTER (
            'Tabela',
            'Tabela'[Date] < _date
                && 'Tabela'[Currency] = _currency
                && 'Tabela'[Exchange rate] <> BLANK ()
        )
    )
VAR _preerate =
    CALCULATE (
        MAX ( 'Tabela'[Exchange rate] ),
        FILTER ( 'Tabela', 'Tabela'[Date] = _predate && 'Tabela'[Currency] = _currency )
    )
RETURN
    IF ( ISBLANK ( 'Tabela'[Exchange rate] ), _preerate, 'Tabela'[Exchange rate] )

vyiruanmsft_0-1718938617841.png

Best Regards

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

1 REPLY 1
v-yiruan-msft
Community Support
Community Support

Hi @krzysztof ,

You can create a calculated column as below to get it, please find the details in the attachment.

Target Column = 
VAR _date = 'Tabela'[Date]
VAR _currency = 'Tabela'[Currency]
VAR _predate =
    CALCULATE (
        MAX ( 'Tabela'[Date] ),
        FILTER (
            'Tabela',
            'Tabela'[Date] < _date
                && 'Tabela'[Currency] = _currency
                && 'Tabela'[Exchange rate] <> BLANK ()
        )
    )
VAR _preerate =
    CALCULATE (
        MAX ( 'Tabela'[Exchange rate] ),
        FILTER ( 'Tabela', 'Tabela'[Date] = _predate && 'Tabela'[Currency] = _currency )
    )
RETURN
    IF ( ISBLANK ( 'Tabela'[Exchange rate] ), _preerate, 'Tabela'[Exchange rate] )

vyiruanmsft_0-1718938617841.png

Best Regards

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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