Return Power BI 中存在的最新值

Return latest value present in power BI

我正在尝试在 Power BI 中创建一个名为最近分数的计算列,它为我提供每个员工的最新分数。

Employee Number Date Score Most recent score 
1234 01/01/2019 1 1
1235 01/01/2019 4 2
1236 01/01/2019 2 3
1288 01/01/2019 0 0
1259 01/01/2019 0 1
1234 01/02/2019 3 1
1235 01/02/2019 4 2
1236 01/02/2019 1 3
1288 01/02/2019 2 0
1259 01/02/2019 4 1
1234 01/03/2019 1 1
1235 01/03/2019 2 2
1236 01/03/2019 3 3
1288 01/03/2019 0 0
1259 01/03/2019 1 1
1234 01/04/2019 BLANK 1
1235 01/04/2019 BLANK 2
1236 01/04/2019 BLANK 3
1288 01/04/2019 BLANK 0
1259 01/04/2019 BLANK 1


我正在使用以下似乎有效的措施,除非最近的分数是“0”,在这种情况下它会通过最近的非“0”分数。

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

任何帮助将不胜感激

已编辑答案

这似乎可以满足您的需求。

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 )
    )