Hello experts,
Need your help on one of my task which I really have no idea how to do it.
It is about a stock aging which I need to group it by certain bucket group, but the main issue is I need to track down when it has stock out (minus qty) it should substract the older qty first which maybe not in the same month (that is if my grouping is by monthly)
The explanation is like this:
For example I have this data :
Item | Date | Qty |
---|---|---|
ItemA | 9/1/2021 | 10 |
ItemA | 10/1/2021 | 5 |
ItemA | 11/1/2021 | 2 |
ItemA | 11/1/2021 | -5 |
ItemB | 10/1/2021 | 3 |
with this kind of grouping for the stock aging bucket:
Age | from | to |
---|---|---|
1 month | 0 | 30 |
2 month | 31 | 60 |
> 2 month | 61 | 9999 |
I want to have the matrix of my stock aging to be like this :
Available | 1 month | 2 month | > 2 month | ||
---|---|---|---|---|---|
ItemA | 12 | 2 | 5 | 5 | |
ItemB | 3 | 0 | 3 | 0 |
ItemB is very simple because it has only 1 value and it has no stock out. but ItemA, there is a special treatment whereby the stock out -3 should substract the qty of the beginning available qty, so because the beginning has a purchase (stock in) of 10, 2 months before, it will need to substract this value.
This is what we usually called it FIFO / First In First Out.
Iāve done some basic like Samās did with the classification but it will give me the wrong one like this :
Available | 1 month | 2 month | > 2 month | ||
---|---|---|---|---|---|
ItemA | 12 | -3 | 5 | 10 | |
ItemB | 3 | 0 | 3 | 0 |
How to have the 1st matrix ? Can DAX support this kind of calculation ?
I attached the sample PBIX for your convenience.
StockAging.pbix (19.2 KB)
It would be much appreciated if you guys can help me out on this.
Thanks