G
GillesScouvart
As part of a safety stock - reorder point analysis, I want to compute the
historical consumption during specified time windows. As a start point, I
have a list of all net consumptions per day (Material|Plant|Date|Consumption).
Till now, I used a not-so-quick-but-dirty method by adding fields in this
table for each length of the time-window (30 days, 60 days, and so on), and
offsetting the date of the consumption by the number of days. Then I use a
Make-table query by
- linking the table to itself (on Material and Plant)
- grouping by Material|Plant|Date
- and summing the consumptions of the copy if their date falls into the time
window.
This takes a long time. I then thought about using Dsum, but I can't get it
working.
SELECT Plant, Material, Date, Quantity, DSum("[T1 Daily consumption].
[Quantity]","[T1 Daily consumption]","[T1 Daily consumption].[Material]='" &
[T1 Daily consumption].[Material] & "' AND [T1 Daily consumption].[Plant]='"
& [T1 Daily consumption].[Plant] & "' AND [T1 Daily consumption].[Posting
date]<#" & DateAdd("d",30,[T1 Daily consumption].[Posting date]) & "# AND [T1
Daily consumption].[Posting date]>=#" & [T1 Daily consumption].[Posting date]
& "#") AS [Cons 30days]
FROM [T1 Daily consumption];
It does work right for some records, and not for others, without apparent
reason.
Any suggestion welcome!
historical consumption during specified time windows. As a start point, I
have a list of all net consumptions per day (Material|Plant|Date|Consumption).
Till now, I used a not-so-quick-but-dirty method by adding fields in this
table for each length of the time-window (30 days, 60 days, and so on), and
offsetting the date of the consumption by the number of days. Then I use a
Make-table query by
- linking the table to itself (on Material and Plant)
- grouping by Material|Plant|Date
- and summing the consumptions of the copy if their date falls into the time
window.
This takes a long time. I then thought about using Dsum, but I can't get it
working.
SELECT Plant, Material, Date, Quantity, DSum("[T1 Daily consumption].
[Quantity]","[T1 Daily consumption]","[T1 Daily consumption].[Material]='" &
[T1 Daily consumption].[Material] & "' AND [T1 Daily consumption].[Plant]='"
& [T1 Daily consumption].[Plant] & "' AND [T1 Daily consumption].[Posting
date]<#" & DateAdd("d",30,[T1 Daily consumption].[Posting date]) & "# AND [T1
Daily consumption].[Posting date]>=#" & [T1 Daily consumption].[Posting date]
& "#") AS [Cons 30days]
FROM [T1 Daily consumption];
It does work right for some records, and not for others, without apparent
reason.
Any suggestion welcome!