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

Null Handling

i have  t1, t2 columns.. . these 2 fields having null values

i would like to subtract these two  t1-t2

when am doing in table level its working fine  as  if(alt(t1,0)-(alt(t2,0))<> 0 ,'NO','same')

but same thing is not working in script level.. how can   i handle  above expression in script level. i would like to show like above  if  t1,t2 values are equals i should  treat this as 'same'   else 'different'.

please help me

7 Replies
Gysbert_Wassenaar

In the script you would have to create a field to store the result of the comparison.


LOAD

     t1,

     t2,

     if(alt(t1,0)-(alt(t2,0))<> 0 ,'NO','same') as FieldNameHere

FROM ...


talk is cheap, supply exceeds demand
Not applicable
Author

i tried  same thing.

but  same  logic is not working properly

varunjain
Creator
Creator

TRY THIS


if(if(isnull(t1),0,t1)-if(isnull(t2),0,t2) <>0,'NO','SAME') as [FIELD NAME]

anbu1984
Master III
Master III

Can you attach sample qvw

varunjain
Creator
Creator

LOAD

     t1,

     t2,

  if(if(isnull(t1),0,t1)-if(isnull(t2),0,t2) <>0,'NO','SAME') as [FIELD NAME]

FROM ...

Gysbert_Wassenaar

Perhaps your data contains text values or strings of spaces so the t1 and t2 columns are interpreted as text instead of as numbers. Try using the num() function: if(alt(num(t1),0)-alt(num(t2),0),'NO','same')


talk is cheap, supply exceeds demand
Not applicable
Author

I think the nulls you are having are due to how the data you are showing in front end (my guess: straight table) over dimensions.

The fields u are using in the chart are coming from one single QV table?

if not you need to replicate the same logic as in front end in the script too and then use the expression given by other members