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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Christian_
Contributor II
Contributor II

Count if (from measures)

Hello everyone,

I have created a calculated measure based on various fields. This evaluates each name with a rating from A to E ('Rating').

Now I would like to show in diagrams how many names ('Names') I have per rating level. Since the rating is a measure and not a dimension, I cannot use it as desired. My approach is therefore to create another separate measure for each rating level (i.e. 5 in total), which I can then use in a bar chart, for example.

Here is my approach for Rating = A

Count(If(Rating = 'A', Name))

and

Count({<Rating = {'A'}>} Name)

Now to my problem: It seems that the reference to 'Rating' as measure in the formula does not work. If I replace it with a field from my script for testing purposes, it works.

Does anyone here have an idea?

Best regards

Christian

Labels (4)
11 Replies
poklegoguy
Creator
Creator

Just wondering what's avoiding you from using Rating as a dimension and Count(Name) as a measure? This way you can see the count of name by different ratings. 

Christian_
Contributor II
Contributor II
Author

Christian__0-1723541124807.png

It simply does not appear in the list under "Add dimension" in the chart. I only have access to the fields here. I could only add it to the chart as a measure.

poklegoguy
Creator
Creator

That's odd. Then how did you get Rating =  A, B etc or even use the field in the set analysis? If the 'Rating' field simply doesn't exist and you can't modify the script, you can create a calculated dimension with ValueList function like ValueList('A', 'B', 'C', 'D', 'E').

Christian_
Contributor II
Contributor II
Author

Roughly summarized: I have fields from the script, have evaluated each of these with variables (score from 0 to 10), which I have then calculated into a total score using a new measure and then converted into a rating using variables. Everything was mainly solved with "if-functions".

The Value List at least shows me something in the diagram, but unfortunately not the correct value 😕

Christian__0-1723542654074.png

Christian__1-1723542707615.png

 

 

 

Kushal_Chawda

@Christian_  what is Rating measure expression?

Christian_
Contributor II
Contributor II
Author

if([Score]>=$(vScoringBewertungA),dual('A',1),
if([Score]>=$(vScoringBewertungB),dual('B',2),
if([Score]>=$(vScoringBewertungC),dual('C',3),
if([Score]>=$(vScoringBewertungD),dual('D',4),
dual('E',5)
)
)
)
)

Kushal_Chawda

@Christian_   create chart with below dimension & measure

Dimension:

= valuelist ('A','B','C','D','E')

Measure:

=pick(match(valuelist ('A','B','C','D','E'),'A','B','C','D','E'),
Count({<[Score]={">=$(vScoringBewertungA)"}>} Name),
Count({<[Score]={">=$(vScoringBewertungB)"}>} Name),
Count({<[Score]={">=$(vScoringBewertungC)"}>} Name),
Count({<[Score]={">=$(vScoringBewertungD)"}>} Name),
Count({<[Score]={">=$(vScoringBewertungE)"}>} Name))

Christian_
Contributor II
Contributor II
Author

Unfortunately, it doesn't work either:

Christian__0-1723556340863.png

Score is also a measure and not just a field from the script. Could this be causing a problem?

Kushal_Chawda

@Christian_  That's what I asked. What is the expression of Score measure?