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: 
orangebloss
Creator
Creator

Multiple And / Or in If statement

 

I'm attempting to show only records where the following criteria are met but finding it's not quite doing what I want:

if the change flag is AN and the mod number begins with T and the part category is B or M and the Mod_number starts with 1 and the component contains / or - then return the component:

=if([BCD CHANGE_FLAG]='AN' AND Mod_no like 'T*' and [BCD Partcategory]='B' or [BCD Partcategory]='M'and Left(Mod_no, 1) = 'T' and (substringcount([BCD COMPONENT], '/')>0 or substringcount([BCD COMPONENT], '-')>0) ,[BCD COMPONENT])

 

What I'm getting is components without a / or - and mod numbers that don't begin with T along with the ones I'm expecting:

orangebloss_0-1689323614104.png

Is it lack of brackets? placement?

 

Thanks in advance!

Labels (4)
1 Solution

Accepted Solutions
marcus_sommer

Your first OR isn't wrapped with brackets like the second one. Beside setting the brackets you may adjust the logic to be able to use only AND connections between the conditions, for example:

if([BCD CHANGE_FLAG]='AN' AND
     Mod_no like 'T*' and
     match([BCD Partcategory], 'B', 'M') and
     Left(Mod_no, 1) = 'T' and
      rangesum(substringcount([BCD COMPONENT], '/'), substringcount([BCD COMPONENT], '-')) ,
[BCD COMPONENT])

View solution in original post

1 Reply
marcus_sommer

Your first OR isn't wrapped with brackets like the second one. Beside setting the brackets you may adjust the logic to be able to use only AND connections between the conditions, for example:

if([BCD CHANGE_FLAG]='AN' AND
     Mod_no like 'T*' and
     match([BCD Partcategory], 'B', 'M') and
     Left(Mod_no, 1) = 'T' and
      rangesum(substringcount([BCD COMPONENT], '/'), substringcount([BCD COMPONENT], '-')) ,
[BCD COMPONENT])