Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
eo4154h
Contributor
Contributor

If Statements to select from fields

So I have a data set with one column listing names of employees and one listing job roles. Field names of the columns are 'Full Name' and 'Title', respectively. I wanted to know how I can use an IF statement to select only the names with job roles containing the words 'Sales' and 'President' and use those selections as a dimension in a filter pane. 

Is there an expression i can use for this?

Thanks

 

Labels (2)
4 Replies
lblumenfeld
Partner Ambassador
Partner Ambassador

Use this expression as the dimension in the filter pane...

=Aggr(Only({< Title={"*president*", "*sales*"} >} Title), Title)

Then change the label to "Title".

This is better than an "if" statement, because it enable Qlik to recognize this as the "Title" field and have it correctly show in the Selections at top.

See more information on this technique in this post on my blog. (http://qlikwithfriends.com/index.php/2018/02/25/using-aggr-instead-of-if-for-complex-dimensions/)

I hope this helps.

nikitadeshwal
Partner - Contributor III
Partner - Contributor III

Hi,

You can use below expression in Filter Pane

=if (Title='Sales' or Title='President', Full_Name)

Regards,

Nikita Deshwal

lblumenfeld
Partner Ambassador
Partner Ambassador

Hi Nikita,

This would work if you wanted to match those exactly, but the request was to do a "contains" comparison. 

The IF statement could still be used is we substitute "WildMatch".

=if (WildMatch(Title, '*Sales*', '*President*'),  Full_Name)

I tend not to use "If" when doing this in filters or dimensions. I use Aggr instead. Take a look at the blog post mentioned in my prior response and you'll see why.

Leslie

Brett_Bleess
Former Employee
Former Employee

You have three replies below and given you have not commented further I am assuming one of them is what you needed, please be sure to close out your thread by returning to it and on any posts that helped, use the Accept as Solution button to mark them which gives the poster(s) credit for the help and lets other Member's know what worked.  It is greatly appreciated if you close out your threads on Community.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.