Forum Discussion

Yashh's avatar
Yashh
Helper II
3 years ago
Solved

Incemental Subtraction

Hello All,

 

Currently I am having this view in Power BI

Sales documentMaterialOrdered QuantityStock.Available QuantityRemaining Stock
2744570105980561533115275
2793574105980561533115275
2744571105980561533115275
2793575105980561533115275

 

But I want to have  this view

Sales documentMaterialOrdered QuantityStock.Available QuantityRemaining Stock
2744570105980561533115275
2793574105980561527515219
2744571105980561521915163
2793575105980561516315107

 

How can I do it and also i have many materials so for every material I have to do it. 

 

I will give an example of the  different materials i have

 

Sales documentMaterialOrdered QuantityStock.Available Quantity
27445701059805615331
27935741059805615331
27445711059805615331
27935751059805615331
2787998105644613
2792122105644613
2793918105644613
278685952222724548
278686052222724548
278686152222724548
278458672632614109
27932115551531186
27968895551531186
27968715551531186
27964925551531186
27965805551531186
27969185551531186
27968905551531

186  

 

Please help me with this.

 

BR 

Yashh Gaikwad

  • Yashh 

    pls try to create an index column and  create two calculated columns

    stock available = 
    VAR _index = CALCULATE(min([Index]),ALLEXCEPT('Table','Table'[Material]))
    return [Stock.Available Quantity]-sumx(FILTER('Table','Table'[Material]=EARLIER('Table'[Material])&&[Index]<=EARLIER('Table'[Index])&&'Table'[Index]>_index),'Table'[Ordered Quantity])
    
    
    
    remaining stock = [Stock.Available Quantity]-sumx(FILTER('Table','Table'[Material]=EARLIER('Table'[Material])&&[Index]<=EARLIER('Table'[Index])),'Table'[Ordered Quantity])

     

1 Reply

  • Yashh 

    pls try to create an index column and  create two calculated columns

    stock available = 
    VAR _index = CALCULATE(min([Index]),ALLEXCEPT('Table','Table'[Material]))
    return [Stock.Available Quantity]-sumx(FILTER('Table','Table'[Material]=EARLIER('Table'[Material])&&[Index]<=EARLIER('Table'[Index])&&'Table'[Index]>_index),'Table'[Ordered Quantity])
    
    
    
    remaining stock = [Stock.Available Quantity]-sumx(FILTER('Table','Table'[Material]=EARLIER('Table'[Material])&&[Index]<=EARLIER('Table'[Index])),'Table'[Ordered Quantity])