Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Catwith_push
Contributor II
Contributor II

Master Calendar Error: Autogenerate: generate count is negative

hi all,

I am using a standard master calendar script but I am getting the error of Autogenerate : Generate count is Negative:

Catwith_push_0-1644340088999.png

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!

 

 

 

1 Solution

Accepted Solutions
Catwith_push
Contributor II
Contributor II
Author

Marcus, Thanks for reply! I tried to load the min/max values and it seems no problem.

Catwith_push_0-1644502928125.png

And I run script again and have the same error. 

 

View solution in original post

4 Replies
marcus_sommer

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

Catwith_push
Contributor II
Contributor II
Author

Marcus, Thanks for reply! I tried to load the min/max values and it seems no problem.

Catwith_push_0-1644502928125.png

And I run script again and have the same error. 

 

hic
Former Employee
Former Employee

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.

Catwith_push
Contributor II
Contributor II
Author

 @hic Thanks a lot!