Forum Discussion

Giancarlo1977's avatar
Giancarlo1977
Frequent Visitor
2 years ago
Solved

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?

  • Hi Giancarlo1977,

     

    You could try such a calculated a column:

     

    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

2 Replies

  • Hi Giancarlo1977,

     

    You could try such a calculated a column:

     

    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