Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Kohli
Creator II
Creator II

Please explain about these variables

Let vTodaysDate = num(makedate(2013,5,31));

Let v12month = num(Makedate(2012,5,31));

Let vRolling12months = Num#($(v12month),'YYYYMM');

Labels (1)
2 Replies
Gysbert_Wassenaar

Let vTodaysDate = num(makedate(2013,5,31));
Let v12month = num(Makedate(2012,5,31));

MakeDate(2013,5,31) will create a date value that corresponds to May 31th 2013. The num function will turn the date value into a number value.  That number is then assigned as value to the vTodaysDate variable. The same happens for the v12month variable. It gets the same value as the vTodaysDate variable.

Let vRolling12months = Num#($(v12month),'YYYYMM');

And this doesn't make sense. $(v12month) will replace put the value of the v12month variable into the num# function. So basically that line becomes Let vRolling12month = Num#(41425, 'YYYYMM');. And that doesn't make sense because 41425 is a number. It's not a string that has to be interpreted as a number so using the num# function is strange. And the num# function cannot use date format strings to interpret numbers so using 'YYYYMM' is wrong too.

 

Conclusion: I can't explain these variables. They don't make sense to me.

 

 

 

 

talk is cheap, supply exceeds demand
lblumenfeld
Partner Ambassador
Partner Ambassador

 

Let vTodaysDate = num(makedate(2013,5,31));

The statement above creates the date 5/31/2013. The Num converts this to the internal number representation that Qlik uses for date (in this case 41425). The "Let" will evaluate the formula and store the result in the variable vTodaysDate.

 

Let v12month = num(Makedate(2012,5,31));

 The statement above does the same thing as the first one, with the 5/31/2012 and stores it in v12month.

 

Let vRolling12months = Num#($(v12month),'YYYYMM');

I'm not sure what the intent of this third statement (above)  is. Currently, it's taking the value of v12month (described above) and interpreting it as a number (which it already is). Given the format string used, I think you meant to use "Date" to format it as year and month number. So,

Let vRolling12months = Date($(v12month),'YYYYMM');

would set vRolling12months to 201205. Is that what you intended?