cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Hannisky
Frequent Visitor

Create table with group and cummulative sum

Hi all. Could use some help 🙏
Not sure if this is done easier in Power Query or DAX, either works for me. 


I need to create a custom table based off of transactions for stock changes. The tricky part is that the correct sum at the end of the month i the total sum of ALL transactions up till that date. I then need to group these per Item and month. Example below:

Here is an extract of the current table and I need to create a new table grouped by Item and whole month with the sum of all previous cost amounts up till that month.  

Hannisky_0-1662383607843.png

 

The end result would be something like this. Item_No summerized, whole month and sum of cost up till that end of month (note not only sum within that month but sum of all previous transaction for that item)

Hannisky_1-1662383765030.png

 

Any help much appreciated 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Hannisky , Create a date table, join with date of you table, add month end date date if needed as column

 

and try a measure like

 

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

 

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



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Hannisky , Create a date table, join with date of you table, add month end date date if needed as column

 

and try a measure like

 

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

 

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



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors