Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem with Null() function

Hi All,

I have a strange problem which I am really not being able to figure out and I request help.

I have an expression which displays variables in this way ,

if($(vYTDTarget_CY_Line_2.b_TS) = 0,null(),

if($(vYTDTarget_CY_Line_2.b_TS) > 0, num(($(vYTD_CY_Line_2.b_TS)-$(vYTDTarget_CY_Line_2.b_TS))/$(vYTDTarget_CY_Line_2.b_TS),'#,##0.0%')

,

if($(vYTDTarget_CY_Line_2.b_TS) < 0 , num(($(vYTDTarget_CY_Line_2.b_TS)-$(vYTD_CY_Line_2.b_TS))/$(vYTDTarget_CY_Line_2.b_TS), '#,##0.0%'))))

According to the values, I have vYTDTarget_CY_Line_2.b_TS evaluate to 0.

I have stored this expression in a variable vLine2b_grade_TS which when I display in a text object as $(vLine2b_grade_TS) I get a - sign ( As I have declared to have all null as " - ")

Now, when I use the following expression in a text box,

if(IsNull(vLine2b_grade_TS), null(),

          if(text(vLine2b_grade_TS)='-0.0%',2,

          If(vLine2b_grade_TS >= 0,4,

          if(vLine2b_grade_TS < -.05,0, 2))))

I get a value of 4. Qlikview is taking the value of vLine2b_grade_TS as 0 instead of null(). Ideally this value should be 0 instead of 4.

Request all your help and suggestions to resolve this.

Thanks,

Tutan

11 Replies
swuehl
MVP
MVP

Variables can never be null, so this test is not useful.

Rob, are you sure about that?

If I define a variable vTest in variable overview like

=NULL()

I can test the variable in an object

=isNull(vTest)

And get -1 / True back.

But I would also give your suggestion a try, though I would also double check the definition and value of vYTDTarget_CY_Line_2.b_TS since this will determine everything else.

tutan4uall, could you create and post a small sample app?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

...Rob, are you sure about that?..

Obviously not

You can assign something that resolves to null in the variable overview as you've indicated. You can also use "=xxx", which resolves to null. Other setting methods - LET, Actions, can do that if they assign the string "=null()" to the variable.

But nothing I know of, including peek(), can assign a direct null value to a variable. So it may be impractical and probably error prone to think of variables as being able to hold null().

-Rob