Forum Discussion
Stock reduction based on demand
Dear All Mastah
Hii everyone I don't have any idea for this measure about inventory, please help. I want to get the results from reducing stock to demand. The point is that the stock calculation will decrease if there is demand on each date. please check table my expectations
Table Demand
| ArticleCode | Date Demand | Demand |
| A001 | 01-Mar | 200 |
| A001 | 02-Mar | 300 |
| A001 | 03-Mar | 200 |
| A001 | 04-Mar | 100 |
| A002 | 01-Mar | 200 |
| A002 | 02-Mar | 300 |
| A002 | 03-Mar | 4,400 |
| A002 | 04-Mar | 11 |
| A002 | 05-Mar | 131 |
| A002 | 06-Mar | 131 |
| A002 | 07-Mar | 313 |
| A002 | 08-Mar | 131 |
| A003 | 03-Mar | 200 |
| A003 | 04-Mar | 100 |
| A003 | 05-Mar | 200 |
| A003 | 06-Mar | 300 |
| A003 | 07-Mar | 1,000 |
| A003 | 08-Mar | 900 |
Table Stock
| ArticleCode | Stock |
| A001 | 10,000 |
| A002 | 9,000 |
| A003 | 5,000 |
My Expectation Matrix
- 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.
1 Reply
- AnonymousNot applicable
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.