Return latest value present in power BI

Jody picture Jody · Sep 24, 2018 · Viewed 9.4k times · Source

I am trying to create a calculated column in power BI called most recent score that gives me the most recent score for each employee.


I am using the below measure which seems to work unless the most recent score is a "0" in which case it pulls through the most recent non "0" score.

Most Recent Score =
VAR MRSM = Master[Employee ID]
RETURN
    CALCULATE (
        LASTNONBLANK ( Master[Score], Master[Score] ),
        FILTER ( Master, Master[Employee ID] = MRSM )
    )

Any help would be appreciated

Answer

Marco Vos picture Marco Vos · Sep 24, 2018

EDITED ANSWER

This seems to do what you need.

Most Recent Score = 
VAR EmpID = 'Master'[Employee ID]
VAR tblScores =
    FILTER ('Master', 'Master'[Employee ID] = EmpID  && NOT ( ISBLANK ( 'Master'[Score] ) )
    )
VAR mrsDate = CALCULATE ( MAX ( [Date] ), tblScores )
RETURN
    CALCULATE ( MAX ( 'Master'[Score] ), FILTER ( tblScores, 'Master'[Date] = mrsDate )
    )

enter image description here