Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
rossybearr
Contributor
Contributor

Multiple IF(Match statements with a Count * XXXX

So I'm new to this and have been working on a combo chart in which I have a list of Actuals and then I need a corresponding line that shows a theoretical number.

I have a custom dimension:

 

If( [Incidents: Classification] = 'Fatality (FAT)', 'FAT',

If(Match([Incidents: Classification], 'Lost Time Case (LTC)','Restricted Work Injury (RWI)'),'SA',

If(Match([Incidents: Classification],'Medical Treatment Case (MTC)','First Aid Case (FAC)'),'Ac',

If(Match([Incidents: Classification],'Near Miss (NM)'),'In',

If(Match([Incidents: Classification],'Unsafe Act (UAC)','Unsafe Condition (USC)'),'RS',NULL(),


)))))

 

My Actual measure is: Count([Incidents: Accident ID])

My Theoretical Measure currently is looking like this:

 

If([Incidents: Classification] = 'Fatality (FAT)',Count([Incidents: Accident ID])*30000,

If(Match([Incidents: Classification],'Lost Time Case (LTC)','Restricted Work Injury (RWI)'),Count([Incidents: Accident ID])*1000,

If(Match([Incidents: Classification],'Medical Treatment Case (MTC)','First Aid Case (FAC)'),Count([Incidents: Accident ID])*100,

If(Match([Incidents: Classification],'Near Miss (NM)'),Count([Incidents: Accident ID])*10,

Count([Incidents: Accident ID]),

))))

 

As you can see from the below image, it does the standard count for RS and the * 10 for In but not the other categories.

 

heinrichpyramid.png

Labels (1)
1 Solution

Accepted Solutions
dwforest
Specialist II
Specialist II

Maybe try an INLINE crosswalk
Weights:
LOAD * INLINE [
[Incident Classifiation],[Weight]
'Fatality (FAT)',30000
'Lost Time Case (LTC)',1000
'Restricted Work Injury (RWI)',1000
...
]
measure then:
Count([Incidents: Accident ID]) * Alt(Weight,1)

View solution in original post

3 Replies
JustinDallas
Specialist III
Specialist III

Can you give us some dummy data that will allow us to reproduce and replicate what's going on ?  The size of that If-statement is approaching unreadable, so I would have to work it in the actual editor to make sure things are "if"-ing out at the correct point.

dwforest
Specialist II
Specialist II

Maybe try an INLINE crosswalk
Weights:
LOAD * INLINE [
[Incident Classifiation],[Weight]
'Fatality (FAT)',30000
'Lost Time Case (LTC)',1000
'Restricted Work Injury (RWI)',1000
...
]
measure then:
Count([Incidents: Accident ID]) * Alt(Weight,1)
rossybearr
Contributor
Contributor
Author

I think I have resolved to doing the count in the load and just adding it as a dimension