Qlik Community

Ask a Question

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Specialist
Specialist

Filtering with generic If Statement

Hi all,

I have 4 fields Class1, Class2, Class3, and Class4 with ID.

I want to filter into 3 buckets based on their values.

If Class1 or Class2 or Class3 or Class4 if greater than 30, then ID as 30+ID,

similarly for other numeric values like 59, 100 etc..

But the if statement i use is not accurate enough and giving all the IDs as result.

Can someone pls look here.

It will be a great help.

1 Solution

Accepted Solutions

I think the second suggestion by swuehl using the RangeMax() is the best idea.

View solution in original post

7 Replies

Try something like this instead for your If's:

     If((Class1 > 30 or Class2 > 30 or Class3 > 30 or Class4 > 30), ID) as [30+ ID],

     If((Class1 > 30 or Class2 > 30 or Class3 > 30 or Class4 > 34), ID) as [34+ ID],

     If((Class1 > 30 or Class2 > 30 or Class3 > 30 or Class4 > 52), ID) as [52+ ID],

     If((Class1 > 30 or Class2 > 30 or Class3 > 30 or Class4 > 104), ID) as [104+ ID]

MVP
MVP

You need to write your condition like

If( (Class1 >30 or Class2 >30 or Class3 > 30 or Class4 > 30), ID) as [30+ ID],

or

if( RangeMax(Class1, Class2, Class3, Class4) >30, ID) as [30+ ID]

Try like this

If((Class1 > 30 or Class2 > 30 or Class3> 30 or Class4 > 30), ID) as [30+ ID],

If((Class1> 34 or Class2> 34 or Class3> 34 or Class4 > 34), ID) as [34+ ID],

If((Class1> 52 or Class2> 52 or Class3> 52 or Class4 > 52), ID) as [52+ ID],

If((Class1> 104 or Class2> 104 or Class3 > 104or Class4 > 104), ID) as [104+ ID]

I think the second suggestion by swuehl using the RangeMax() is the best idea.

View solution in original post

Specialist
Specialist

Thanq Mr. Bill.

It's working.

Specialist
Specialist

Thanq Mr. Avinash,

It's working.  I learnt a new thing today.

Specialist
Specialist

Thanq

This worked too.