Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Null values coming for variables in load script

Hello Experts,

I am quite new to Qlikview. I have written some logic in incremental load and I am not getting any values when debug it.

  Let vMaxMonth = Date(MonthEnd(Addmonths(Peek('MaxMonth',0,'Max_Date'),-1)),'MM/DD/YYYY hh:mm:ss:fff');

  Let vMinMonth = Date(MonthStart(Addmonths(Peek('MaxMonth',0,'Max_Date'),-13)),'MM/DD/YYYY hh:mm:ss:fff');

Here MaxMonth is coming from max(field) from table.


I am not able to see any values for vMinMonth and vMaxMonth.


I am not able to debug where it is going wrong.


Thanks in advance

17 Replies
Anonymous
Not applicable
Author

MK_QSL
MVP
MVP

Not sure but you can try

Let vMaxMonth = TimeStamp(MonthEnd(Addmonths(Peek('MaxMonth',0,'Max_Date'),-1)),'MM/DD/YYYY hh:mm:ss:fff');

Let vMinMonth = TimeStamp(MonthStart(Addmonths(Peek('MaxMonth',0,'Max_Date'),-13)),'MM/DD/YYYY hh:mm:ss:fff');

or

Let vMaxMonth = Date(Floor(MonthEnd(Peek('MaxMonth',0,'Max_Date'),-1)))

Let vMinMonth = Date(Floor(MonthStart(Peek('MaxMonth',0,'Max_Date'),-13)))

sunny_talwar

Try this:

Let vMaxMonth = Date(MonthEnd(Addmonths(Peek('MaxMonth'),-1)),'MM/DD/YYYY hh:mm:ss:fff');
Let vMinMonth = Date(MonthStart(Addmonths(Peek('MaxMonth'),-13)),'MM/DD/YYYY hh:mm:ss:fff');
nilesh_gangurde
Partner - Specialist
Partner - Specialist

Please check format of max(field) .

if its date format then fine, or if its text ten we have convert the same into date format using date# function.

Regards,

Nilesh

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Big trick to debug your assignments with nested function calls: start by figuring out which one of the nested calls produces unexpected values (like a NULL or something that isn't a date or a numerical value). Do simplify your expressions, or break them down in stages.

For example:

Let vMaxMonth1 = Peek('MaxMonth',0,'Max_Date');

Let vMaxMonth2 = Addmonths(Peek('MaxMonth',0,'Max_Date'),-1);

Let vMaxMonth3 = MonthEnd(Addmonths(Peek('MaxMonth',0,'Max_Date'),-1));


One of them will fail. Most probably the Peek() although I don't know for sure. Remember that both field and table names are case sesnsitive. Moreover Peek() won't complain if it can't find one of them.

Best,

Peter

Anonymous
Not applicable
Author

Thanks to everybody for replying.

whatever the value will be coming in that variables with that I have to compare with timestamp(DD/MM/YYYY hh:mm:ss) format in further steps.

Here Max(field) is timestamp(DD/MM/YYYY hh:mm:ss).


sunny_talwar

Are you going to be testing equality (=) or greater than/less than (>, >=, <, <=)? Equality with timestamp won't be good idea. So if we are going to test greater than/less than, then I don't think you need the time component, unless you want to start from lets say Jan 1st 2016 9:30 pm instead of Jan 1st 2016 12:01 am.

Anonymous
Not applicable
Author

Thanks Sunny for your quick reply.

Actually I am having greater than/less than (>, >=, <, <=)


I have like below.


Where visit_created_date >= '$(vMaxMonth)' and site_visit_created_datetime <='$(vMinMonth)'.


Where visit_created_datet < '$(vMinMonth)'.


Anonymous
Not applicable
Author

Hi Peter,

I am getting date values. Can u look into this screen shot