Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
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

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
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

Please add me Anil_Babu_Samineni to interact faster when reply back. Speak low think High.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
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.