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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
D19PAL
Creator II
Creator II

Why does this if statement not work

Hi

Why doesn't this if statement work? Or how can I do this?

 

Id,company 

1,ford 

1, vw

2,ford

2,bmw

2,mini

Load

Id,

If(company = 'ford' and company <> 'mini,1) as test

 

I'd ,test

1,1

2,0

 

Thanks

 

 

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Something like:

tresesco_0-1637831143093.png

 

t1:
Load * Inline [
Id,company 
1,ford 
1, vw
2,ford
2,bmw
2,mini];

t2:
Load
	Id,
	If(WildMatch(Concat(DISTINCT company), '*ford*') And
		Not WildMatch(Concat(DISTINCT company), '*mini*')
		,1,0) as test
Resident t1 Group By Id;

Drop Table t1;		 

View solution in original post

6 Replies
abhijitnalekar
Specialist II
Specialist II

Hi @D19PAL,

Please correct the expression If(company = 'ford' and company <> 'mini',1)

 

and it will help us to understand if you also share the required output.  

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
D19PAL
Creator II
Creator II
Author

This is what I require,  I know it won't work, but how can I make it work.

 

 

abhijitnalekar
Specialist II
Specialist II

Hi @D19PAL ,

I can help you, but if let me know what exactly you are looking from this expression

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
tresesco
MVP
MVP

Something like:

tresesco_0-1637831143093.png

 

t1:
Load * Inline [
Id,company 
1,ford 
1, vw
2,ford
2,bmw
2,mini];

t2:
Load
	Id,
	If(WildMatch(Concat(DISTINCT company), '*ford*') And
		Not WildMatch(Concat(DISTINCT company), '*mini*')
		,1,0) as test
Resident t1 Group By Id;

Drop Table t1;		 
D19PAL
Creator II
Creator II
Author

Perfect, there may be more help required lol, watch this space.

D19PAL
Creator II
Creator II
Author

How can I do this if I didn't know the name of the company in field company?  It works a treat with the fields I know the outcome, but I got another field like company where I don't know the values in the field. 

 

Thanks