Wednesday, 11 June 2025

DAX measure to get the Id record of last updated date

Problem:
I have a case where I need to display only the latest updated record for a Id.
In the below image I need to display only the record which is updated on 11-06-2025 (Latest)




Solution:

DAX Measure

IsLatestActivity = 
VAR CurrentIQMS = MAX('POR D'[Id])
VAR CurrentDate = MAX('POR D'[Updated Date])

VAR LatestRow =
    TOPN(
        1,
        FILTER(
            ALL('POR D'),
            'POR D'[Id] = CurrentIQMS
        ),
        'POR D'[Updated Date], DESC
    )
RETURN
IF (
    COUNTROWS(
        FILTER(
            LatestRow,
            'POR D'[Id] = CurrentIQMS &&
            'POR D'[Updated Date] = CurrentDate
        )
    ) > 0,
    1,
    0
)

No comments:

Post a Comment