Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi. I'm new to the community so go easy on me [:)]
I'm trying to calculate daily quantities based on a range of dates (start date and end date). I'll try and explain a little better through a simple example:
StartDate | EndDate | Qty |
01/10/10 | 05/10/10 | 10 |
02/10/10 | 03/10/10 | 6 |
The 'Qty' should be spread across all the days in the range meaning 2 (10/2) is counted for 5 days for the first record and 3 is counted for 2 days from the second record. This boils down to the two records above producing the following output (to chart)
Date | Qty for that day |
01/10/10 | 2 |
02/10/10 | 5 |
03/10/10 | 5 |
04/10/10 | 2 |
05/10/10 | 2 |
(I hope I've worked this out right!)
I'm resigned to the fact the answer will probably involve aggr functions of some kind but thinking about them too much just makes me aggry!
Thanks Guys
Maria
Should have said that the dates are in dd/mm/yy format - Sorry!
Hello Maria,
I don't understand very much the "2 counted for 5 days" part, but using intervalmatch will do. Check the code and comments in this post to see if that helps. Although the fields are differents, but I think it may help you.
Regards.
The "2 counted for 5 days" just means spreading the Qty of 10 across the range of 5 days. 10 divided by 5 equals 2.
I've had a look at that example you linked and some others. They look applicable but they look like they go the wrong way around. By that I mean they look like they're looking for a range a given date is in where I'm looking to take a range and expand it into given days.
Or maybe I'm missing something?
Hello!!Maria,
Check attached QVW .
Regards,
Dixit Patel
That's a really neat use of the Interval function I remember from my training course!
Thanks very much, I'll give it a try.
Maria