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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

View discussion in a popup

Replying to:
Jihwan_Kim
Super User

Hi, I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I tried to show latest date sales per each country, and each country shows different latest date. And I tried to use TREATAS DAX function in the measure.

 

TREATAS function - DAX | Microsoft Learn

 

 

 

 

Last date sales: =
VAR _periodselect =
    MAX ( 'calendar'[Date] )
VAR _t =
    SUMMARIZECOLUMNS (
        country[country],
        'calendar'[Date],
        FILTER ( ALL ( 'calendar' ), 'calendar'[Date] <= _periodselect ),
        "@sales", SUM ( fact_table[sales] )
    )
VAR _latestdate =
    ADDCOLUMNS (
        _t,
        "@latestdate",
            MAXX (
                FILTER ( _t, country[country] = EARLIER ( country[country] ) ),
                'calendar'[Date]
            )
    )
VAR _treatas =
    SUMMARIZE ( _latestdate, country[country], [@latestdate] )
RETURN
    CALCULATE (
        SUM ( fact_table[sales] ),
        TREATAS ( _treatas, country[country], 'calendar'[Date] )
    )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.