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

Check if variable is null?

I have this variable (null by default) that changes based on the user selection, using the qsVariable extension.

However, I want my formulas display a specific value when there is no selection (when the app is first opened for example).

Here's what I've tried:

If(IsNull($(vSelectedMonth)),'T','F') -- returns "-"

If(IsNull(vSelectedMonth),'T','F') -- returns 'F', even without any selection

If(Len($(vSelectedMonth))<1,'T','F') -- returns "-"

If(Len(vSelectedMonth)<1,'T','F') -- returns 'T', seems to work correctly, however when I apply the same logic to another variable, it doesn't work (returns "-"):


If(Len(vSelectedMonth)<1,

Dual(Year(Monthstart(Today(),-1))&'-'&Month(Monthstart(Today(),-1)),MonthStart(Today(),-1)),

Dual(Year(Monthstart(MakeDate(2018,$(vSelectedMonth),1)))&'-'&Month(Monthstart(MakeDate(2018,$(vSelectedMonth),1))),

MakeDate(2018,$(vSelectedMonth),1)))

Any ideas?

2 Replies
william_fu
Creator II
Creator II
Author

Got it to work by removing the dollar sign expansions from the formula:

If(Len(vSelectedMonth)<1,

Dual(Year(Monthstart(Today(),-1))&'-'&Month(Monthstart(Today(),-1)),MonthStart(Today(),-1)),

Dual(Year(Monthstart(MakeDate(2018,(vSelectedMonth),1)))&'-'&Month(Monthstart(MakeDate(2018,(vSelectedMonth),1))),

MakeDate(2018,(vSelectedMonth),1)))

Don't quite know why that works, so explanations are welcome!

zebhashmi
Specialist
Specialist

to me, it Should work without () even. I think $ is for the second layer of calculation.

Regards