I have a stock movement table with 4 columns - SKUID, productID, dateIn, dateOut and amount. I wish to be able to track stock levels over time ie on each date in a given range what was the stock level of a given productID - e.g.
(Source Data)
SKUID, productID, dateIn, dateOut, amount 100001, 5, 10/01/2014, 15/01/2014, 500 100002, 5, 10/01/2014, 15/01/2014, 1000 100003, 5, 20/01/2014, 31/12/2049, 500 100004, 5, 20/01/2014, 20/01/2014, 100
(Report Data)
productID, date, amount 5, 10/01/2014, 1500 5, 11/01/2014, 1500 5, 11/01/2014, 1500 ... 5, 15/01/2014, 0 5, 15/01/2014, 0 ... 5, 20/01/2014, 500 5, 21/01/2014, 500
For each day in the final report I want to see the sum of amount for each product where the dateIn is <= reportDate and dateOut is >= reportDate.
I think this should be done as some kind of conditional sum - ie create a calculated measure as follows :-
sum({null:[dateIn].[Date].CurrentMember}, iif([StockMovement].[dateOut] >= [dateIn].[Date].CurrentMember, [Measures].[Amount], 0))
this doesn't work - it simply gives me the sum of amount for each dateIn