Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
madeleine_josef
Contributor

Count distinct?

I have the following data and as can be seen there is one row for each question, each of these rows have the same (assignment)number.

How can I count how many different (assignment)numbers I have? Right now when I count I get 13 times as many as I would like as the (assignment) number appears 13 times for each questionaire.

Thanks!

1 Solution

Accepted Solutions
okolyug16
Contributor II

Re: Count distinct?

try this Count(DISTINCT number)

13 Replies
okolyug16
Contributor II

Re: Count distinct?

try this Count(DISTINCT number)

Re: Count distinct?

May be this:

Count(DISTINCT question)

ishanbhatt
Contributor II

Re: Count distinct?

Hi Madeleine,

It Seems you want only distinct values of the umber column.

Use below expression in measure.

= Count( Distinct  number).

As per Above images this expression will give result 2.

madeleine_josef
Contributor

Re: Count distinct?

I tried Count (DISTINCT number) but it gives me the total number of (assignment)numbers as it is connected to another table (Assignment) with all assignment(numbers).

Is there any way to calculate only those in a special qvd file (QualityReportAnswer)?

In my qvd files I have renamed the field numbers to AnswerAA.

Re: Count distinct?

Hi,

You can do one thing, the table from where you need the Count, you can add one more dummy field like

Load *,'ABC' as Source

From xyz;

Now in expression you can use the set analysis to get the count only from that table like below.

Count({<Source = {"ABC"}>} distinct Number)

Regards,

Kaushik Solanki

inoruoya
New Contributor III

Re: Count distinct?

you should add another name field from AnswerAA

ex: 1 as AnswerAACount,

and you can count(AnswerAACount) or sum(AnswerAACount)

try this.

Employee
Employee

Re: Count distinct?

Perhaps the count on the key field questions is causing you to include too many items, as it would count over all linked tables. Try counting on a non-key field, for example Count(DISTINCT QuestionName) with the assumption that QuestionName is an unique as your question number.

madeleine_josef
Contributor

Re: Count distinct?

I could get your suggestion to work Kaushik Solanki, or yours either Toni Kautto.

However I tried to add a duplicate of my filed numbers that isn't connected to any other table. This one I used in a count instead, this worked.

Re: Count distinct?

So which field did you end up using to do the count here? and if possible briefly describe why do you think it worked for you and if you have got what you wanted, please close the thread by marking your own response as correct.

Best,

Sunny