Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

count distinct

I have a set of data with the following info:

MEM#, FV_GROUP

123      FV

456      FV

753      NFV

963      FV

456      FV

769      NFV

I like to get a distinct count of the MEM#.

The result, I like to see is

FV has a count of 3

NFV has a count of 2

The expression I have right now is

=count(distinct(MEM#))

How can change the expression so that I can check the FV_GROUP.

Thanks.       

6 Replies
deepakk
Partner - Specialist III
Partner - Specialist III

Hi,

Is this what you are looking for . PFA

Anonymous
Not applicable
Author

Hi,

Can you please post the code? I only have the desktop version so I cannot view the qvw. Thanks.

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

You have written the correct code. Just add it in expression of a chart and add the FV_Group as dimension.

Anonymous
Not applicable
Author

Here is my expresssion

Count(${< FV_GROUP = {‘FV’}>} DISTINCT MEM#)

but I am not getting any result. Just a -

What am i doing wrong.

Thanks.

nagaiank
Specialist III
Specialist III

If you want to calculate this in a chart, you may use the following chart expression:

Count(DISTINCT TOTAL <FV_GROUP> MEM#)

If you want add this as a field in the script, use the following script:

T1:

LOAD *, RowNo() as ID;

LOAD * Inline [

MEM#,FV_GROUP

123,FV

456,FV

753,NFV

963,FV

456,FV

769,NFV

];

T2:

LOAD FV_GROUP, Count(DISTINCT MEM#) as Cnt Resident T1 Group By FV_GROUP;

Left Join (T1) LOAD FV_GROUP, Cnt Resident T2;

DROP Table T2;

deepakk
Partner - Specialist III
Partner - Specialist III

hi,

The dollar should be inside the bracket.

count({$<FV_GROUP={'FV'}>} distinct MEM#)

Deepak