Forum Discussion

drivas771994's avatar
drivas771994
Icon for Helper II rankHelper II
8 years ago
Solved

Is there a formula for calculating the difference between rows.

Hi,

 

I'm trying to calculate the difference between two values in the same column. For example, I have a student (John Doe) who took one test on 9/1/2018 and received a 76 and then retook the test on 9/5/2018 and got an 88. I want to make a calculated column for the difference in the scores. Is this possible? And would it be specific to each individual student?

7 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    drivas771994

     

    Try this pattern

     

    Difference from Previous Score =
    VAR previousrow =
        TOPN (
            1,
            FILTER (
                Table1,
                [Student] = EARLIER ( [Student] )
                    && [Test Date] < EARLIER ( [Test Date] )
            ),
            [Test Date], DESC
        )
    VAR previousscore =
        MINX ( previousrow, [Score] )
    RETURN
        IF ( NOT ( ISBLANK ( previousscore ) ), [Score] - previousscore )