Forum Discussion

sandeepk66's avatar
sandeepk66
Icon for Advocate I rankAdvocate I
8 years ago
Solved

Need Cumulative Sum by Item

Hi Geeks,
Need Cumulative Sum of the AMOUNTper each Item.
I have created a column ' Cumulative Sum' in Excel, which is basically AMOUNT+Qty-Liability  per Item.

needed to replicate same in PowerBIDesktop,

Any Ideas would be appreciated.

 

Link to Dashboard pbix

Excel Data

 

  • Phil_Seamark's avatar
    Phil_Seamark
    8 years ago

    Hi Again sandeepk66

     

    In anycase, here is a calculated column that might work

     

    Column = 
    VAR StartRowAmount = MINX(FILTER(Examples,'Examples'[ITEM] = EARLIER('Examples'[ITEM])),'Examples'[AMOUNT])
    RETURN 
        CALCULATE(
                            StartRowAmount + 
                            SUM([SALE Amount]) - 
                            SUM([Liability])
                            , FILTER(
                            ALL('Examples'),
                            'Examples'[RowID] <= EARLIER('Examples'[RowID]) 
                            && 'Examples'[ITEM] = EARLIER('Examples'[ITEM]))
                            )

     

     

5 Replies

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

    Hi sandeepk66

     

    Just checking.  In the first line of each of your product groupings, you use three column to determine the result, then from that result, the next lines only use 2 columns.  Is that what you meant to do, or was that a typo?

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

      Hi Again sandeepk66

       

      In anycase, here is a calculated column that might work

       

      Column = 
      VAR StartRowAmount = MINX(FILTER(Examples,'Examples'[ITEM] = EARLIER('Examples'[ITEM])),'Examples'[AMOUNT])
      RETURN 
          CALCULATE(
                              StartRowAmount + 
                              SUM([SALE Amount]) - 
                              SUM([Liability])
                              , FILTER(
                              ALL('Examples'),
                              'Examples'[RowID] <= EARLIER('Examples'[RowID]) 
                              && 'Examples'[ITEM] = EARLIER('Examples'[ITEM]))
                              )