Forum Discussion

Le-menace's avatar
Le-menace
Icon for Helper I rankHelper I
5 years ago
Solved

Cumulative calculated column (grouped by)

I have a simple table with daily records which I want to accumulate in a new column (a measure is not an option due to other stuff I'd like to do afterwards).

 

I've managed to find an easy way to make such a column in this forum, but not how to do the accumulation "grouped by" another column. 

 

I've tried to make a screen pic that shows what I need to do below:

This cumulative column accumulates every value regardless of 'name'. I want the cumulation to be group by the names..

 

Would very much appreciate any insights.

 

Best regards,

  • Please try this column expression instead, replacing Table with your actual table name throughout.

     

    Cumulative Total =
    VAR __thisdate = Table[Date]
    RETURN
        CALCULATE (
            SUM ( Table[Value] ),
            ALLEXCEPT (
                Table,
                Table[Name]
            ),
            Table[Date] <= __thisdate
        )

     

    Regards,

    Pat

     

2 Replies

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft Employee

    Please try this column expression instead, replacing Table with your actual table name throughout.

     

    Cumulative Total =
    VAR __thisdate = Table[Date]
    RETURN
        CALCULATE (
            SUM ( Table[Value] ),
            ALLEXCEPT (
                Table,
                Table[Name]
            ),
            Table[Date] <= __thisdate
        )

     

    Regards,

    Pat