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

if condition compare two IDs

 

NewField - If (ID1 = Notfound, check ID2 else keep ID1,) please refer screenshot for better understanding. 

Capture.PNG

LOAD * INLINE [
Name, ID1, ID2
Red, Notfound,
Pink, Notfound,
Blue, 45654565,
Red, Notfound, 520022386
Green, Notfound, 520022386
Red, 45456456,
Red, 78945265, 78945265
Green, 22165466, 22165466
Pink, 46545489,
Blue, 54848963,
];

1 Solution

Accepted Solutions
_ylc
Partner - Creator
Partner - Creator

Hi,

Your load inline is different from the screenshot for items Red and Green. Anyway.

Not sure if this is what you want, basically created an if condition that if ID=Notfound, it will still check the ID2. If the ID2 is empty then it will take ID1 .

temp:
LOAD * INLINE [
Name, ID1, ID2
Red, Notfound,
Pink, Notfound,
Blue, 45654565,
Red, Notfound, 520022386
Green, Notfound, 520022386
Red, 45456456,
Red, 87979956, 78945265
Green, 84516566, 22165466
Pink, 46545489,
Blue, 54848963,
];

LOAD Name, if(ID1 = 'Notfound', if(len(ID2)=0, ID1, ID2), ID1)
resident temp;

drop table temp;

 

View solution in original post

2 Replies
_ylc
Partner - Creator
Partner - Creator

Hi,

Your load inline is different from the screenshot for items Red and Green. Anyway.

Not sure if this is what you want, basically created an if condition that if ID=Notfound, it will still check the ID2. If the ID2 is empty then it will take ID1 .

temp:
LOAD * INLINE [
Name, ID1, ID2
Red, Notfound,
Pink, Notfound,
Blue, 45654565,
Red, Notfound, 520022386
Green, Notfound, 520022386
Red, 45456456,
Red, 87979956, 78945265
Green, 84516566, 22165466
Pink, 46545489,
Blue, 54848963,
];

LOAD Name, if(ID1 = 'Notfound', if(len(ID2)=0, ID1, ID2), ID1)
resident temp;

drop table temp;

 

rajaxavier
Contributor
Contributor

Tab :
LOAD * INLINE [
Name, ID1, ID2
Red, Notfound,
Pink, Notfound,
Blue, 45654565,
Red, Notfound, 520022386
Green, Notfound, 520022386
Red, 45456456,
Red, 78945265, 78945265
Green, 22165466, 22165466
Pink, 46545489,
Blue, 54848963,
];

Tab1:
Load
*,
if(isnum(ID1),ID1,if(isnum(ID2),ID2,ID1)) as ID3
Resident Tab;

Drop table Tab;