Last View - Dax Measure

Hello,

I am trying to identify the last viewed report within the last 2 months (rolling), where “Action” column = “Read”, however I would like to see only 1 instance per report (So the report field must be unique). I do have a report id in real data, but not in the sample file.

Here is the expected outcome:
image

Here is my DAX measure attempt:

Last Report =
VAR _Period = DATESINPERIOD(data[Latest_Date],MAX(data[Latest_Date]),-2,MONTH)
Return
CALCULATE(COUNTROWS(data),Filter(data,data[Action] =“Read”), Max(data[Latest_Date]) in _Period)

Any help is much appreciated.

Sample data attached.
Last Report.pbix (27.0 KB)

Thanks, H

Hi @Hesham ,

Thanks for posting this question and providing PBIX file along with required output. It makes it easy for us to provide solution quickly.

Please find below measure to get required output:

Last Viewed Report =
VAR GetLastDate =
    CALCULATE (
        MAX ( 'data'[Latest_Date] ),
        DATESINPERIOD ( data[Latest_Date], MAX ( data[Latest_Date] ), -2, MONTH ),
        FILTER ( data, data[Action] = "Read" )
    )
RETURN
    CALCULATE ( GetLastDate, FILTER ( data, data[Action] = "Read" ) )

image

Kind Regards,
Hafiz

Thank you @hafizsultan. Working as expected.

1 Like