Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Count distinct with set_expression

Hello,

I need to count the number of occurrences of a name within a week in a year

I tried something like that:

=COUNT( DISTINCT <WeekNumberOfTheYear> Name)

But it doesn't work.

Can anyone help me, please?

Thanks.

N.

11 Replies
senpradip007
Specialist III
Specialist III

try this:

create week number in calendar of your app.

Count({<WeekNo = {'$(=Max(WeekNo))'}, Date=, Day= >} Distinct Name)

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Distinct is in the wrong place;

=COUNT(<WeekNumberOfTheYear> DISTINCT Name)


HTH

Jonathan


PS = this is ignoring selections in a field called [WeekNumberOfTheYear]

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
kiranmanoharrode
Creator III
Creator III

Dear Edp,

Try below Script

Test:

Laod Date,

         Name

from Datasource;

Test1:

Load Week(Date) as WeekNo,

          year(Date) as Year,

          Count(Distinct Name) as NameCount

resident Test

Group by WeekNo, Year;

Drop table Test;

Regards
Kiran

Anonymous
Not applicable
Author

Hi Kiran,

I need the function in the chart, not in the script.

Thank you.

N.

Anonymous
Not applicable
Author

Hi Jonathan,


I switched as you explained, but it's doesn't work again (the result is an '-').


Thank you.


N.

Anonymous
Not applicable
Author

Hi,

I tried as you explained (I calculated WeekNo As Year*100+Week, so I have 201401, 201402 and so on...), but the result is always 0.

Thank you.

N.

MK_QSL
MVP
MVP

You can create a Straight Table with

WeekNumber as Dimension

and

Count (Distinct Name) as Expression.

sundarakumar
Specialist II
Specialist II

Please elaborate your requirement.

What is the dimension u r using? and in what type of chart?

u want to count the number of occurance of a particular name in a partucular week of a year or in all weeks of the year?

Try to post a sample data and expected output.

-Sundar

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

As we are all just guessing at the problem now, it would be a good idea to post your qvw with some sample data so that can be looked at in more detail.

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein