Forum Discussion

minasaleh669's avatar
minasaleh669
New Member
4 years ago
Solved

Cumulative Total excluding some data

Hello everyone,

in this table START_Date & END_DATE columns have 3 values or more (values and their sum), I want to get cumulative for sum values only.... thank u for ur help 

 
  • Hi minasaleh669,

     

    You may try this Measure.

    CumulativeTotalExcludingData =
    VAR cumulativeTotal =
        CALCULATE (
            SUM ( 'Table'[ACT_COST] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[END_DATE] ),
                'Table'[Index] <= MAX ( 'Table'[Index] )  //sum by the order in the screeshot
                //'Table'[WBS_ID] <= MAX ( 'Table'[WBS_ID] ) //sum by WBS_ID ascending
            )
        )
    RETURN
        IF (
            MAX ( 'Table'[START_DATE] ) >= DATE ( 2019, 5, 1 )
                && MAX ( 'Table'[START_DATE] ) <= DATE ( 2019, 7, 1 ),
            cumulativeTotal,
            BLANK ()
        )

     

    As this Measure calculates cumulative total by the order in the screenshot, you need add an extra index column in Power Query Editor(Transform Date). If you just would like to get cumulative total by the order of WBS_ID ascending, then you can try the annotated code.

     

    The result looks like this.

     

    Also, attached the pbix file.

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun

4 Replies

  • v-cazheng-msft's avatar
    v-cazheng-msft
    Community Support

    Hi minasaleh669,

     

    You may try this Measure.

    CumulativeTotalExcludingData =
    VAR cumulativeTotal =
        CALCULATE (
            SUM ( 'Table'[ACT_COST] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[END_DATE] ),
                'Table'[Index] <= MAX ( 'Table'[Index] )  //sum by the order in the screeshot
                //'Table'[WBS_ID] <= MAX ( 'Table'[WBS_ID] ) //sum by WBS_ID ascending
            )
        )
    RETURN
        IF (
            MAX ( 'Table'[START_DATE] ) >= DATE ( 2019, 5, 1 )
                && MAX ( 'Table'[START_DATE] ) <= DATE ( 2019, 7, 1 ),
            cumulativeTotal,
            BLANK ()
        )

     

    As this Measure calculates cumulative total by the order in the screenshot, you need add an extra index column in Power Query Editor(Transform Date). If you just would like to get cumulative total by the order of WBS_ID ascending, then you can try the annotated code.

     

    The result looks like this.

     

    Also, attached the pbix file.

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun