Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Easy Sum Based on Dates Current/Previous Question

I have a Table with two columns - month, a #. I am trying to make a third calculated column that adds the current month with the lines above it to get a total. ex:

MonthNumberNumberYTD
7/1/20202323
8/1/20202144
9/1/20202266
10/1/20202288
11/1/202021109
12/1/202023132
1/1/202121153
2/1/202120173
3/1/202123196

I tried:

NumerYTD = calculate(sum(Table[Number]),Filter(Table,Table[Month]<=Table[Month]))

but that just gives me 196 for every line.

TYIA

  • Anonymous ,

     

    Try this code for a new calculated column:

    Number YTD = CALCULATE(SUM('Table'[Number]), FILTER('Table', 'Table'[Month] <= EARLIER('Table'[Month])))

1 Reply

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

    Anonymous ,

     

    Try this code for a new calculated column:

    Number YTD = CALCULATE(SUM('Table'[Number]), FILTER('Table', 'Table'[Month] <= EARLIER('Table'[Month])))