Forum Discussion
Stock reduction based on demand
- Anonymous2 years ago
Hi,admera
Regarding the issue you raised, my solution is as follows:
1. First, the stock value is referenced into the main table using the calculated column:
INTIStock = LOOKUPVALUE('Table Stock'[Stock],'Table Stock'[ArticleCode],'Table Demand'[ArticleCode])2.Then depending on your needs, I create the following calculated columns individually:
Balance = var _sum= SUMX( FILTER(ALL('Table Demand'), 'Table Demand'[Date Demand]<=EARLIER('Table Demand'[Date Demand])&&'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])),[Demand]) return [INTIStock] - _sumStock = var _date= MAXX(FILTER(ALL('Table Demand'), 'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])&&'Table Demand'[Date Demand]<EARLIER('Table Demand'[Date Demand])),[Date Demand]) var _value= SUMX( FILTER(ALL('Table Demand'), 'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])&&'Table Demand'[Date Demand]=_date),[Balance]) return IF( _value<>BLANK(),_value,[INTIStock])3.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,admera
Regarding the issue you raised, my solution is as follows:
1. First, the stock value is referenced into the main table using the calculated column:
INTIStock = LOOKUPVALUE('Table Stock'[Stock],'Table Stock'[ArticleCode],'Table Demand'[ArticleCode])
2.Then depending on your needs, I create the following calculated columns individually:
Balance =
var _sum=
SUMX(
FILTER(ALL('Table Demand'),
'Table Demand'[Date Demand]<=EARLIER('Table Demand'[Date Demand])&&'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])),[Demand])
return
[INTIStock] - _sum
Stock =
var _date=
MAXX(FILTER(ALL('Table Demand'),
'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])&&'Table Demand'[Date Demand]<EARLIER('Table Demand'[Date Demand])),[Date Demand])
var _value=
SUMX(
FILTER(ALL('Table Demand'),
'Table Demand'[ArticleCode]=EARLIER('Table Demand'[ArticleCode])&&'Table Demand'[Date Demand]=_date),[Balance])
return
IF(
_value<>BLANK(),_value,[INTIStock])
3.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.