Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

markgraham123
Contributor II

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.

Tags (2)
1 Solution

Accepted Solutions

Re: Filtering with generic If Statement

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

7 Replies

Re: Filtering with generic If Statement

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

Re: Filtering with generic If Statement

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]

Re: Filtering with generic If Statement

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]

Re: Filtering with generic If Statement

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

markgraham123
Contributor II

Re: Filtering with generic If Statement

Thanq Mr. Bill.

It's working.

markgraham123
Contributor II

Re: Filtering with generic If Statement

Thanq Mr. Avinash,

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

markgraham123
Contributor II

Re: Filtering with generic If Statement

Thanq

This worked too.

Community Browser