Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
ProveluNL
Frequent Visitor

DAX calculated column summation by category with values previous and current record

Hello,

 

I have the following table (goods movements) and want to calculate total qty (current row) by adding current qty to total qty (previous row). Who can help me?

Calculated ColumnCalculated Column

1 ACCEPTED SOLUTION
ProveluNL
Frequent Visitor

I found the answer:
Sum Qty =

VAR CurrArtId = [Art_id]
VAR CurrTr_Id = [Tr_id]
RETURN
CALCULATE(
SUM(Goods_movement[Qty]);
FILTER(ALL(Goods_movement);
AND(Goods_movement[Art_id] = CurrArtId ; Goods_movement[Tr_id] <= CurrTr_Id)
) )
example2.png
 
 

View solution in original post

3 REPLIES 3
ProveluNL
Frequent Visitor

I found the answer:
Sum Qty =

VAR CurrArtId = [Art_id]
VAR CurrTr_Id = [Tr_id]
RETURN
CALCULATE(
SUM(Goods_movement[Qty]);
FILTER(ALL(Goods_movement);
AND(Goods_movement[Art_id] = CurrArtId ; Goods_movement[Tr_id] <= CurrTr_Id)
) )
example2.png
 
 
YJ
Resolver II
Resolver II

Hi,

might not be the best efficient way but you get what you want:

20191022_BI_ProveluNL.JPG

Cal_Tot_Qty = CALCULATE(SUM(Table1[Qty]),FILTER(Table1,Table1[Tr_id]<EARLIER(Table1[Tr_id])+1))
put this in your cal column.
Our ans differ, check your ID row 4,7 . if i understand correctly, this should be it.
 
regards
ProveluNL
Frequent Visitor

Thanks for your help.

But the counting should start over again when the ART (article id) changes.

Rgrds

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.