Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Trey
Contributor II
Contributor II

Simple If/Or question

Hi - I'm new to Qlik Sense but making quite a bit of headway. I've loaded my data and am working on building multiple sheets from this data. The first sheet is going to be a table and charts associated with vehicle accidents. The second sheet will focus on workers compensation claims. The third sheet will be different as well.

I'm having trouble determining which is the best way to set up these sheets. The original data has information for all of these type of events and each event is labeled as a vehicle accident, workers compensation, etc.

Is the best way to set up these sheets for the specific types of claims just to write an expression that filters out everything except for the claims I'm looking for? For example on the vehicle accident sheet, should I just filter out all claims except for the "Auto - BI" and "Auto - PD" cases?

If yes, then I need help on writing an expression. I wrote =if([TYPE]='Auto - BI',[TYPE]) and this worked, but I need to include an "OR" statement to include Auto - PD too. I'm having trouble writing this expression and I'm not seeing much online about how to write a simple OR expression to include both Auto - BI and Auto - PD while filtering out any other types of claims.

Any help would be appreciated.

Thanks

 

2 Replies
uroboros
Creator
Creator

Hi @Trey,

 

you have many possibilities that could solve your needs. One of them, and I think it could be the fastest to implement, would be to create the type field that you mention, and add an action inside each sheet that allows you to filter the type of data you need just when you open the sheet.

Another option that occurs to me right now is that you use analysis set for your calculations according to the sheet: Type = {'Accident'}, for example.

 

 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Generally, you want to use a Set Analysis expression instead of If() for this scenario.  For example, if you wanted a table chart of claim counts by Type.

Dimension:  Type

Measure:
Count({<[TYPE]={'Auto -BI', 'Auto-PD'}>}ClaimId)

You can simplify this by creating a new field "ClaimClass" in your data model, that has the values "Auto" "Worker", etc.  Then, instead of listing all the Auto types you can use:

Count({<[ClaimClass]={'Auto'}>}ClaimId)

In your load script, you create the ClaimClass field by using a Mapping table that maps the various TYPE values into a ClaimClass. 
https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes...

Again, the recommendation is to use set analysis. But if you needed/wanted to use if(), the syntax for OR is:

=if([TYPE]='Auto - BI' or [TYPE]='Auto - PD',[TYPE]) 

Although the better way to test for multiple values is Match().

=if(Match([TYPE], 'Auto - BI',  'Auto - PD'),[TYPE]) 

https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalFun...

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com