Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi all,
I am using a standard master calendar script but I am getting the error of Autogenerate : Generate count is Negative:
And here is my script:
StartAndEndDates:
LOAD
MIN([Order Date]) AS FirstOrderDate,
MAX([Order Date]) AS LastOrderDate
RESIDENT Order;
LET vFirstDate = NUM(PEEK('FirstOrderDate', 0, 'StartAndEndDates'));
LET vLastDate = NUM(PEEK('LastOrderDate', 0, 'StartAndEndDates'));
TempCal:
LOAD
DATE($(vFirstDate) + ROWNO()- 1) AS TempDate
AUTOGENERATE
$(vLastDate)-$(vFirstDate) + 1;
MasterCalendar:
LOAD
TempDate AS [Order Date],
WEEK(TempDate) AS Week,
YEAR(TempDate) AS Year,
MONTH(TempDate) AS Month,
DAY(TempDate) AS Day,
WEEKDAY (TempDate) AS Weekday,
'Q' & CEIL(MONTH(TempDate) / 3) AS Quarter,
WEEK(TempDate) & '-' & YEAR(TempDate) AS WeekYear
RESIDENT TempCal;
DROP TABLES StartAndEndDates, TempCal;
would anyone have an idea for solving this issue? Thank you!
Marcus, Thanks for reply! I tried to load the min/max values and it seems no problem.
And I run script again and have the same error.
There is no real issue obvious whereby your variables are empty respectively don't exists. This may happens if your OrderDate isn't a real date else a string. In this case the min/max-query won't contain a numeric value and the following num() within the variable-assignment will fail and returning NULL which the deletes the variables.
- Marcus
Marcus, Thanks for reply! I tried to load the min/max values and it seems no problem.
And I run script again and have the same error.
I suspect that you use "Qualify" in your script, so that the two fields are called "StartAndEndDates.FirstOrderDate" and "StartAndEndDates.LastOrderDate".
If so, the PEEK('FirstOrderDate', 0, 'StartAndEndDates') will return NULL. Try
PEEK('StartAndEndDates.FirstOrderDate', 0, 'StartAndEndDates')
instead.
@hic Thanks a lot!