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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Giancarlo1977
Frequent Visitor

Cumulative subraction in Column

Hi,

 

I am looking for a formula that should give me the result as per table below in last column "Cumulative remaining stock"

 

Countryserial numberItem NumberConcatenateQTY Item Number in stockQty Item Required for each serial numberCumulative remining stock
US111aUS_a211
US222aUS_a210
US333aUS_a21-1
US444aUS_a21-2
Canada555aCanada_a312
Canada666aCanada_a311
Canada777aCanada_a310
Canada888aCanada_a31-1

 

I have different serial number that are using the same item number. So I want to calculate the remaining stock considering that all of them are using the same item. In addition I should consider a filter for the country.

 

Can you please help?

1 ACCEPTED SOLUTION
barritown
Super User
Super User

Hi @Giancarlo1977,

 

You could try such a calculated a column:

barritown_0-1701334192493.png

 

Here's the code in plain text for convenience:

Cumulative remaining stock = 
VAR CurrentSelection = [Concatenate]
VAR CurrentSN = [serial number]
VAR Delta = SUMX ( FILTER ( 'Table', [Concatenate] = CurrentSelection && [serial number] <= CurrentSN ), [Qty Item Required for each serial number] )
RETURN [QTY Item Number in stock] - Delta

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

View solution in original post

2 REPLIES 2
Giancarlo1977
Frequent Visitor

Thanks a lot @barritown,

it is working perfectly for me!

 

Regards

 

Giancarlo

barritown
Super User
Super User

Hi @Giancarlo1977,

 

You could try such a calculated a column:

barritown_0-1701334192493.png

 

Here's the code in plain text for convenience:

Cumulative remaining stock = 
VAR CurrentSelection = [Concatenate]
VAR CurrentSN = [serial number]
VAR Delta = SUMX ( FILTER ( 'Table', [Concatenate] = CurrentSelection && [serial number] <= CurrentSN ), [Qty Item Required for each serial number] )
RETURN [QTY Item Number in stock] - Delta

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors