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.
avatar user

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)