Forum Discussion
vipett
Helper III
2 years agoDAX remaining sum after deductions
I'm trying to look at our demand going forward and the current stock levels. For example, if we in January have 20 in demand and 50 in stock, then nothing needs to go to step two (breakdown to compo...
vipett
Helper III
2 years agoI have tried this so far, but it basically just takes the demand - stock and doesn't consider if the stock was consumed previously.. (in this case I ignored the customer..)
RemainingDemand =
VAR CurrentMonth = Table[Month]
VAR CurrentProduct = Table[UnifiedItemNumber]
VAR PreviousStock =
CALCULATE (
SUM ( Table[Stock] ),
FILTER (
Table,
Table[UnifiedItemNumber] = CurrentProduct
&& Table[Month]= MAXX (
FILTER (
Table,
Table[UnifiedItemNumber] = CurrentProduct
&& Table[Month] < CurrentMonth
),
Table[Month]
)
)
)
VAR CurrentDemand = Table[Total]
RETURN
IF (
PreviousStock >= CurrentDemand,
0,
IF ( PreviousStock = 0, CurrentDemand, CurrentDemand - PreviousStock )
)