Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Cumulative total

Hi All,

I want to calculate the cumulative value for below table.

MonthActual
September0.4
October4.0
November0
December0
January0
February0
March0
April0
May0
June0
July0
August0

 

 

The expected output should be like below, I have data only for the month September and October. My Trendline should show all the months and the cumulative data should be calculated till month.

MonthActualCumulative
September0.40.4
October4.04.4
November00
December00
January00
February00
March00
April00
May00
June00
July00
August00
  • Hi Anonymous 

     

    add a column with this code:

    Month No. = 
    month(DATEVALUE("2021/"&[Month]&"/01"))

     

    then try this measure:

    Cumulative 1 = 
    Var _A =CALCULATE(sum('Table'[Actual]),filter(all('Table'),'Table'[Month No.]<=max('Table'[Month No.])))
    return
    if(max('Table'[Actual])=0,0,_A)

     

    output:

     

     

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

    Appreciate your Kudos!!

     

1 Reply

  • Hi Anonymous 

     

    add a column with this code:

    Month No. = 
    month(DATEVALUE("2021/"&[Month]&"/01"))

     

    then try this measure:

    Cumulative 1 = 
    Var _A =CALCULATE(sum('Table'[Actual]),filter(all('Table'),'Table'[Month No.]<=max('Table'[Month No.])))
    return
    if(max('Table'[Actual])=0,0,_A)

     

    output:

     

     

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

    Appreciate your Kudos!!