Forum Discussion

Adam_cordell_ma's avatar
Adam_cordell_ma
Regular Visitor
5 years ago
Solved

Remove rolling total/cumulative effect from a sequence of amounts

Hey there, I want to remove rolling total/cumulative effect from a sequence of amounts?  My data looks like this Date Account Region Amount 31/01/2016 n123456 US 10 31/03/201...
  • Pragati11's avatar
    5 years ago

    Hi Adam_cordell_ma ,

     

    First thing whihc is very important, do add the sample data in such a format that anyone can copy and paste it in Power BI easily. Best way of doing it is sharing it in a csv file and uploading it to dropbox and then sharing the dropbox link here.

    Also, I am not sure your output sample is right. The highlighted row should return 21 not 50. Because the calculation is previous row amount subtracted from current row AMOUNT. Please confirm this.

    If my understanding is right on your question, You can try something as below.

    Fisrt I created an INDEX column on your sample data:

     

    Then I created the following DAX caluclation:

    CalcAmount =
    VAR currentIndex =
        MAX ( testTable[Index] )
    VAR currentAmt =
        SUM ( testTable[Amount] )
    RETURN
        ABS (
            currentAmt
                - (
                    CALCULATE (
                        SUM ( testTable[Amount] ),
                        FILTER ( ALL ( testTable ), testTable[Index] = currentIndex - 1 )
                    )
                )
        )

     

    The output is shown as below:

     

    The output displays an ABSOLUTE value.

     

    Thanks,

    Pragati