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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
M_Lhermitte
Contributor
Contributor

Count distinct in script

Hello everyone,

I am currently trying to use the "count distinct" in my script. However, I face an issue when loading the data. Qlik tells me that I have an "invalid expression". Could you please help me solving my issue?

Thanks,

Marguerite

 

The script is:

NoConcatenate
[inst_per_course_1]:

Load
[Course],
[CourseIdentifier],
[CourseTypeFamily],
[CustomerType],
[TraineeCode],
Trigram,

count(DISTINCT Trigram) as nb_instructor

resident [MyTable]
group by Course
;

 

 

Is it better to used 2 separate tables? (I also have an "invalid expression" issue when loading data.) as:

NoConcatenate
[inst_per_course_1]:

Load
[Course],
[CourseIdentifier],
[CourseTypeFamily],
[CustomerType],
[TraineeCode],
Trigram

resident [MyTable]
;

NoConcatenate
[inst_per_course_2]:

Load *,

count(DISTINCT Trigram) as nb_instructor

resident [inst_per_course_1]
group by [Course]
;

Labels (2)
1 Reply
kaushiknsolanki
MVP
MVP

The error is coming because you have not included all the other fields in group by list. 

Try this.

The script is:

NoConcatenate
[inst_per_course_1]:

Load
[Course],
[CourseIdentifier],
[CourseTypeFamily],
[CustomerType],
[TraineeCode],
Trigram,

count(DISTINCT Trigram) as nb_instructor

resident [MyTable]
group by [Course],
[CourseIdentifier],
[CourseTypeFamily],
[CustomerType],
[TraineeCode],
Trigram;

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!