Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

summerrain
New Contributor III

Set analysis and Count Function

My data set is this:

IDGender
1Female
2Male
3Female
4Male
5Female
6Male
7Female
8Male
9Female
10Male

I have a listbox and two text box:

gender.JPG

Tex box has these expressions:

='Female: '&count( {$<Gender={'Female'}>} ID)

='Male: '&count( {$<Gender={'Male'}>} ID)

I am wondering If anybody knows why set analysis doesn't work here: If I choose Female in the list box it still shows 5 Male in the text box. I know I can achieve correct count with getselectedcount function, but what to do If I want to use set analysis and that it would take into account all the selections? I though $ symbol should do the trick, but id doesn't in this case.

Please also see the app attached.

Tags (2)
1 Solution

Accepted Solutions
Highlighted

Re: Set analysis and Count Function

Try this

='Female: '&count( {$<Gender *= {'Female'}>} ID)

='Male: '&count( {$<Gender *= {'Male'}>} ID)

9 Replies
YoussefBelloum
Esteemed Contributor

Re: Set analysis and Count Function

Hi,

what are you trying to do ?

when you choose Female, you want the text box "Male" shows 0 ?

Highlighted

Re: Set analysis and Count Function

Try this

='Female: '&count( {$<Gender *= {'Female'}>} ID)

='Male: '&count( {$<Gender *= {'Male'}>} ID)

vishsaggi
Esteemed Contributor III

Re: Set analysis and Count Function

May be try these

='Female: '&count( {< Gender = {"=GetFieldSelections(Gender) = 'Female' "} >} ID)

='Male: '&count( {< Gender = {"=GetFieldSelections(Gender) = 'Male' "} >} ID)

effinty2112
Honored Contributor

Re: Set analysis and Count Function

Hi Vytautas,

The set expression {$<Gender={'Male'}>} tells the aggregation function it is used in to disregard user selections for Gender and instead return the result as if 'Male' had been selected. The whole idea of set analysis is to allow expressions be be calculated over records that are not restricted solely to user selections in the document. For your purposes try Sum(DISTINCT if(Gender = 'Male',ID)).

Regards

Andrew

Partner
Partner

Re: Set analysis and Count Function

='Female: '&if(GetFieldSelections(Gender)='Female', count( {$<Gender={'Female'}>} ID),0)

='Male: '&if(GetFieldSelections(Gender)='Male', count( {$<Gender={'Male'}>} ID),0)

Try this..

Regards,

Mohammad

YoussefBelloum
Esteemed Contributor

Re: Set analysis and Count Function

Hi Sunny,

first time i see this.. can you explain the meaning of the STAR here ?

Thanks

YB

Re: Set analysis and Count Function

YoussefBelloum
Esteemed Contributor

Re: Set analysis and Count Function

Very nice post, thank you !

summerrain
New Contributor III

Re: Set analysis and Count Function

As always, amazing, Thanks!