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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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