Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
9 years ago
Solved

Misunderstanding Lookupvalue

Hello all,  I'm trying to do something which on the surface seems very simple but I'm struggling to make it work.   I have a table of users which are taking periodic tests.  I've created a measur...
  • Sean's avatar
    Sean
    9 years ago

    Anonymous

    There are several things you can do first

    Last Score Measure 1 = 
    CALCULATE (
        LASTNONBLANK ( 'Table'[Score], 1 ),
        VALUES ( 'Table'[Student] ),
        LASTDATE ( 'Table'[Date] )
    )

    Or you can imporve the above by calculating the average score for all students that took a test on the last day to be displayed in the total row

    Last Score Measure 2 =
    IF (
        HASONEVALUE ( 'Table'[Student] ),
        CALCULATE (
            LASTNONBLANK ( 'Table'[Score], 1 ),
            VALUES ( 'Table'[Student] ),
            LASTDATE ( 'Table'[Date] )
        ),
        DIVIDE (
            CALCULATE (
                SUM ( 'Table'[Score] ),
                VALUES ( 'Table'[Student] ),
                LASTDATE ( 'Table'[Date] )
            ),
            CALCULATE ( DISTINCTCOUNT ( 'Table'[Student] ), LASTDATE ( 'Table'[Date] ) ),
            0
        )
    )

    My Measures work with or without a separate student table!

    Hope this helps! :smileyhappy: