Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Rolling SUm

Hi,

I have some issue in calculating the rolling Sum

Jan1
feb2
Mar3
Apr4
May5

i need dynamic cummulative total based on slicer (Month) selection
for example if Feb and mar are selected then the result should be 

Feb2
Mar5

If mar and may are selected then the result should be 

Mar3
May8


Thanks in Advance

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    Try to create the following measure.

     

    Measure = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),[Date]<=MAX('Table'[Date])))

     

    Sample data is as follows. A date field is required.

    Below are the results.

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

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

    Anonymous Do you have any other columns like an Index or Date? If so you could do this:

    Measure =
      VAR __Table =
        ADDCOLUMNS(
          'Table',
          "Rolling", SUMX(FILTER(ALLSELECTED('Table',[Index]<=EARLIER('Table'[Index])),[Value])
        )
      VAR __Result = SUMX(__Table,[Rolling])
    RETURN
      __Result
  • Hi,

    Do you have a proper Data column?  If not, then do you have a year column - I will build the Date from the Month and year columns.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Try to create the following measure.

     

    Measure = CALCULATE(SUM('Table'[Value]),FILTER(ALLSELECTED('Table'),[Date]<=MAX('Table'[Date])))

     

    Sample data is as follows. A date field is required.

    Below are the results.

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.