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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors