Forum Discussion

CasperSV's avatar
CasperSV
Helper II
2 years ago
Solved

Running total per category

Hi guys,   I am trying to make a Line diagram with 3 lines: Cashflow type 1, Cashflow type 2 and Cashflow type 3. I found out that the following formula works to get a Running total per Cashflow t...
  • amitchandak's avatar
    2 years ago

    CasperSV , Create a separate date table, join with date of your table(without timestamp) and use measures like

     

    example

     

    Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date])))

    Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(allselected(date),date[date] <=max(date[Date])))

    Cumm Based on Date = CALCULATE([Net], Window(1,ABS,0,REL, ALL('date'[date]),ORDERBY('Date'[date],ASC)))

    Cumm Based on Date = CALCULATE([Net], Window(1,ABS,0,REL, ALLSELECTED('date'[date]),ORDERBY('Date'[date],ASC)))

     

    Running Total/ Cumulative:
    https://www.youtube.com/watch?v=h2wsO332LUo&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=42

     

    Continue to explore Power BI Window function Rolling, Cumulative/Running Total, WTD, MTD, QTD, YTD, FYTD: https://youtu.be/nxc_IWl-tTc
    https://medium.com/@amitchandak/power-bi-window-function-3d98a5b0e07f

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi CasperSV ,

     

    Please try code as below to update your measure.

    Running Count =
    CALCULATE (
        SUM ( Samengevoegd[Bedrag incl. BTW] ),
        FILTER (
            ALLSELECTED ( Samengevoegd ),
            Samengevoegd[Cashflow datum] <= MAX ( Samengevoegd[Cashflow datum] )
                && Samengevoegd[Cashflow type] <= MAX ( Samengevoegd[Cashflow type] )
        ),
        VALUES ( Samengevoegd[Cashflow type] )
    )

     

    Best Regards,
    Rico Zhou

     

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