cancel
Showing results for
Did you mean:
Highlighted ## 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.

Excel Data

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted Microsoft

## Re: Need Cumulative Sum by Item

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]))
)``` Proud to be a Datanaut!

5 REPLIES 5
Highlighted Microsoft

## Re: Need Cumulative Sum by Item

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?

Proud to be a Datanaut!

Highlighted Microsoft

## Re: Need Cumulative Sum by Item

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]))
)``` Proud to be a Datanaut!

Highlighted ## Re: Need Cumulative Sum by Item

Appreciated for your work, its working for that example I Provided.

However, its not working for this scenario. Please find the EXCEL and pbix.

Thank you!

Here is the Data

Here is the pbix file

Highlighted Microsoft

## Re: Need Cumulative Sum by Item

Try adding this code as a calculated column to your Query1 table, rather than to your Examples table.

Also, I note the data in your INVENTTRANSID column is not in order.  Is that important?

```CUMColumn2 =
VAR StartRowAmount = MINX(
FILTER(Query1,'Query1'[NAME] =EARLIER('Query1'[NAME])),'Query1'[PHYSICALINVENT])
RETURN
CALCULATE(
StartRowAmount +
SUM(Query1[RECEIPTQTY]) -
sum(Query1[ISSUEQTY])
, FILTER(
ALL('Query1'),
'Query1'[INVENTTRANSID] <= EARLIER('Query1'[INVENTTRANSID])
&& 'Query1'[NAME] = EARLIER('Query1'[NAME]))
)```

Proud to be a Datanaut!

Highlighted ## Cumulative Sum by Dimension for each Transaction Date

Appreciated your inputs.

However,Its not working for the same NAME for that day.

Please see the Issue that I ran into:
Issue example 1
Issue example 2

Can we do this Cumulative Sum by Dimension in Power Query?

Announcements #### Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members. #### Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start. #### Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries! Top Solution Authors
Top Kudoed Authors
Users online (613)