Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count a variable

I'm new to Qlik,

I have a variable that give 1 or 0 for a list of person (whatever the formula that give 1 or 0 for each person).

How can I count the number of 1 ?
I've tried :

count(

{<Variable>={'1'}} Name

)

But it doesn"t work. Any idea?

Thanks in advance

5 Replies
trdandamudi
Master II
Master II

May be as below:

Count ({<$(=Variable)={1}>} Name)

bgerchikov
Partner - Creator III
Partner - Creator III

Hi Thirumala,

You cannot use variable this way in Set Analysis. Try to use expression itself instead.

Upload it if you can.

trdandamudi
Master II
Master II

As Boris pointed out below the above expression will not work.... Below is the expression that will work:

=Count({<Name={"=$(Variable)=1"}>} Name)

Please see the attached sample file for more details.  In the sample app I created two fields Id and Name. There are four names which starts with 'A'. I created a Variable and assigned a formula saying if the first letter of the Name is 'A' then 1 else 0. Hope this helps.....

Not applicable
Author

Hi Thirumala,

I wasn't able to open our file as I'm using qlik sense desktop.

but your correction was right! Now it's working !!

Thanks a lot for the help!

Clever_Anjos
Employee
Employee

As soon as you have only 0´s and 1´s you can Sum(FlagField)