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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
TomBond77
Specialist
Specialist

Match with or / and not working

Hi experts

I have this in my script:

if(match ([Accident], 'false') or len([Accident])=0 and
match(Category,'Incident', 'Accident', 'Fatality'),'X',0) as [Result]

But this is not working. For "Accident" two of the values are relevant, either 'false" or Null. Additionally we need to check on Category with the values mentioned above.

Where is the error?

Thank you!

3 Replies
Arek92
Contributor III
Contributor III

Hi,

What about using IsNull() function instead of Len() ?

Then your formula would look sth like this:

if(match ([Accident], 'false') or IsNull([Accident]) and
match(Category,'Incident', 'Accident', 'Fatality'),'X',0) as [Result]

Arek92
Contributor III
Contributor III

I just also realised you might need to put your first logical condtion inside additional brackets:

if( match ([Accident], 'false') or len([Accident])=0 ) and
match(Category,'Incident', 'Accident', 'Fatality'),'X',0) as [Result]

JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @TomBond77 

Do you have a sample dataset to use for testing?

Using the below (And just adding trim) it seems to work?? 

JandreKillianRIC_0-1739197861774.png

 

 

Load 
	*, 
	(if(match ([Accident], 'FALSE') or len(Trim([Accident]))=0) and
		match(Category,'Incident', 'Accident', 'Fatality'),'X',0) as [Result]; 
Load * Inline [
Rec,Accident,Category
1,TRUE,Incident
2,FALSE,Accident
3,,Accident
4,TRUE,Fatality
5,TRUE,Fatality
6,,Accident
7,FALSE,Incident
];

 

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn