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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors