Forum Discussion
Calculate availability (dates in columns)
Greetings colleagues.
I would like to ask for some help with following problem
I want to calculate availability of product (item ID) for each week
Availability is = OnHand - Ordered (from today to week in column) + Receipt (from today to week in Column)
Attached you will find Excel file with some sample Data and pbix file with same data.
I managed to solve it if my dates (weeks in my example) are in rows, but i would like to do it when dates are columns and items are rows, this is because in real case i have more than 1000 of items.
Here is DAX for Available that i used with Dates as rows
Available =
var ORD = CALCULATE(SUM(Orders[Ordered]), FILTER(ALL(Dates[Date]), Dates[Date] <= max(Dates[Date])))
var OH = calculate(sum(OnHand[OnHand]), REMOVEFILTERS(OnHand[OnHand]))
VAR RCPT = calculate(SUM(Recipept[Reciept QTY]),FILTER(all(Dates[Date]), Dates[Date] <= max(Dates[Date])))
return
OH + RCPT - ORD
Sample Data:
This is how i would like to have my result =
In each empty cell i would like to calculate Available as OnHand - Ordered (from today to week in column) + Receipt (from today to week in column)
| Item_id | OnHand | Week 32 | Week 33 | Week 34 | Week 35 | Week 36 | Week 37 | Week 38 |
| 1000001 | 100 | |||||||
| 1000002 | 200 | |||||||
| 1000003 | 300 | |||||||
| 1000004 | 400 | |||||||
| 1000005 | 500 | |||||||
| 1000006 | 600 | |||||||
| 1000007 | 700 | |||||||
| 1000008 | 800 | |||||||
| 1000009 | 900 | |||||||
| 1000010 | 1000 |
Thank you in Advance.
Hi Anonymous ,
Based on your description, I tried the following test.
OH = CALCULATE(SUM(OnHand[OnHand]),ALLEXCEPT(Dates,Dates[Week]))ORD RT = VAR ORD = CALCULATE ( SUM ( Orders[Ordered] ), FILTER ( ALL ( Dates[Date] ), Dates[Date] <= MAX ( Dates[Date] ) ) ) RETURN ORD
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- v-henryk-mstfCommunity Support
Hi Anonymous ,
Based on your description, I tried the following test.
OH = CALCULATE(SUM(OnHand[OnHand]),ALLEXCEPT(Dates,Dates[Week]))ORD RT = VAR ORD = CALCULATE ( SUM ( Orders[Ordered] ), FILTER ( ALL ( Dates[Date] ), Dates[Date] <= MAX ( Dates[Date] ) ) ) RETURN ORD
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.