Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

atanthony
New Contributor II

Filter a dimension using an If OR statement

I want to filter a field on a bar chart using an If OR statement in expression editor. The field title is ActivityType, there are six different activities types. I want to filter on three of them.  This is what I enter in the expression editor:

    =if(ActivityType='Call' OR (ActivityType='Mailers' OR ActivityType='Drop-In', ActitityType)

This creates for the tress activity types, and a fourth bar that combines the value for all of the activities types.  The legend shows on the three activity types that I filtered on.  What do I need to do to exclude the fourth bar?

Tags (1)
1 Solution

Accepted Solutions
devarasu07
Honored Contributor II

Re: Filter a dimension using an If OR statement

Hi

try like this

Dimension:

=pick(match(ActivityType,'Call','Mailers','Drop-In'),'Call','Mailers','Drop-In')

// suppress null value in this dimension

measure:

sum(Amt)


and then enable total in your bar chart. thanks

Capture.JPG

Capture.JPG

Regards,

Deva


8 Replies
luismadriz
Valued Contributor

Re: Filter a dimension using an If OR statement

HI,

Canyou please share the screenshot?

Maybe just this: =if(ActivityType='Call' OR ActivityType='Mailers' OR ActivityType='Drop-In', ActivityType)

luismadriz
Valued Contributor

Re: Filter a dimension using an If OR statement

Oh and more importantly don't include Nulls

devarasu07
Honored Contributor II

Re: Filter a dimension using an If OR statement

Hi

try like this

Dimension:

=pick(match(ActivityType,'Call','Mailers','Drop-In'),'Call','Mailers','Drop-In')

// suppress null value in this dimension

measure:

sum(Amt)


and then enable total in your bar chart. thanks

Capture.JPG

Capture.JPG

Regards,

Deva


MVP
MVP

Re: Filter a dimension using an If OR statement

A little simpler

=If(Match(ActivityType, 'Call', 'Mailers', 'Drop-In'), ActivityType)

(and suppress null values)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
atanthony
New Contributor II

Re: Filter a dimension using an If OR statement

The attached docx file shows the expression and the resulting bar chart.  The gray at the top of each bar represents the other activity types.  The legend does not include these activity types. How can I exclude them from the bars?

atanthony
New Contributor II

Re: Filter a dimension using an If OR statement

Exactly what I need.  Thank you.

luismadriz
Valued Contributor

Re: Filter a dimension using an If OR statement

By not including nulls on the properties of that dimension

Untitled.png

I hope this helps,

Luis

luismadriz
Valued Contributor

Re: Filter a dimension using an If OR statement

And as per your screenshot, the dimension seems to be Day

Community Browser