Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to count the total of distinct text occurrences from a field


Hello everyone,

Imagining that i have a field called "Flag" and 3 distinct text values:

Candidate

Incumbent

No Incumbent

I need to count the total number of occurrences of "Incumbent" and "No incumbent", and not count the total number of Candidates from the field "Flag".

If i use count (Flag), i will have the total ocurrences of the 3 values, but i jus want the total of "Incumbent" + "No Incumbent".

I don´t know how to do that, once i am counting text values.

Thanks,

Rodrigo

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

COUNT({<Flag = {"Incumbent","No Incumbent"}>}Flag)

View solution in original post

9 Replies
MK_QSL
MVP
MVP

COUNT({<Flag = {'Incumbent','No Incumbent'}>}Flag)

pamaxeed
Partner - Creator III
Partner - Creator III

count({<Flag={"Incumbent","No Incumbent"}>} Flag)

OR

if(Flag="Candidate", null(), Count(Flag))

Clever_Anjos
Employee
Employee

COUNT({<Flag = {"Incumbent","No Incumbent"}>}Flag)

pamaxeed
Partner - Creator III
Partner - Creator III

Digvijay_Singh

try this -

=Count(if(Flag = 'Incumbent' or Flag = 'No Incumbent',Flag))

Not applicable
Author

Thanks for your answer guys!!

I am not sure where do i have to include the script COUNT({<Flag = {"Incumbent","No Incumbent"}>}Flag).

In the chart expression?

Inside the table script?

In the calculated dimension?

Clever_Anjos
Employee
Employee

Set analysis are expressions to be evaluated in graphs, lists, variables and other objects, never at script level.

You should use it where you want to see that value, a text box for example

MK_QSL
MVP
MVP

COUNT({<Flag = {"Incumbent","No Incumbent"}>}Flag) / COUNT(TOTAL {<Flag = {"Incumbent","No Incumbent"}>}Flag)

Not applicable
Author

OK, now i have another situation...

I need to create a chart that shows the gender percentage of people that are only "Incumbent" and "No Incumbent".

So i have to use the dimension "Gender" and use the same expression used above?

Thanks!