Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
markgraham123
Specialist
Specialist

General if statement

Hi,

I'm trying to create a new fileds using and in if statement. But i'm not getting any result.

But a simple if statement is not working. I know there should be something wrong in my syntax.

Can someone please help?

Table1:

LOAD * Inline

[

ID, Name

1,A

1,B

1,C

1,D

1,E

];

Table2:

LOAD *,

If(Name='A' and Name='B' and Name='D' and Name='D' and Name='E' , 'special') as test

Resident Table1;

DROP Table Table1;

10 Replies
Anil_Babu_Samineni

May be this?

If(Name='A' or Name='B' or Name='D' or Name='D' or Name='E' , '5', Name) as test

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

Name cannot be A and B and D ...

it could be A or B fr example

markgraham123
Specialist
Specialist
Author

No Anil.

ID can have multiple names.

Depending on what names the ID has i havre to create a category field.

Above is one of the example.

markgraham123
Specialist
Specialist
Author

ID can have multiple names.

Depending on what names the ID has i havre to create a category field.

Above is one of the example.

Anil_Babu_Samineni

Then, you must explain real data which demonstrates the issue

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

??? could you elaborate it a bit more please?

vishsaggi
Champion III
Champion III

Try this may be?

If(Match(Name, 'A','B','C','D','E'), 'Special') as test

el_aprendiz111
Specialist
Specialist

Hi Mark

/option 1
Table1:
LOAD *, if(WildMatch(Name,'A','B','D','E'),'SPE','OTHER') AS newFieldTest;
LOAD * Inline
[
ID, Name
1,A
1,B
1,C
1,D
1,E
]
;


//option 2
CHRS:MAPPING LOAD * INLINE [
Name, Test
A, SPE
B, SPE
C, OTHER
D, SPE
]
;


Table1:
LOAD *, ApplyMap('CHRS',Name,'OTHER') AS newFieldTest;
LOAD * Inline
[
ID, Name
1,A
1,B
1,C
1,D
1,E
]
;

eduardo_dimperio
Specialist II
Specialist II

Mark, i dont know if i right understant, but Id could have multiple values, but only one per line.

Name could be A or B or C or D or E, but not all at the same time.

So change your AND to OR.