Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
sbeard
Contributor II
Contributor II

Counting Instances in a Table

Hello, 

I would like to count the number of times that different values appear in a table. There is an 'ID' column and I would like to generate an 'Instances' column that counts up the number of times a value appears. For example, if the 'ID' = 2, the calculation will find all the instances where this is true and give the result. I would like it not to be hard-coded to look for individual ID numbers, as the data changes a lot. I have attached an example of how I would like the data to be shown. I would like to avoid using the script editor as most of my data is managed in the data manager. 

Any help appreciated, Sophie 🙂

sbeard_0-1693319691268.png

 

Labels (4)
1 Reply
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Sophie,

I assume that you want this to be done in the script, correct? So, if your original data table is called Tab1, I'd use something like this:

LEF JOIN (Tab1)

LOAD

     ID,

     count(ID) as [Instances of ID]

resident

     Tab1

GROUP BY

     ID

;

To learn more advanced development techniques, check out the agenda of the Masters Summit for Qlik - coming soon to Orlando and to Dublin!