Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Jo94
Contributor II
Contributor II

Counting occurences before a date

Hello everybody, I have a table with some IDs and dates of registration. As presented in the attached file, I need to count the occurence of IDs in order to know how much times the single ID was registered before the date of the row. In Excel I achieved this by manually sorting the date column and using a count.if() function in the column where I need the value. I totally ignored the date, but I achieved what I need. Can you help me doing this with Qlik?
2 Replies
martinpohl
Partner - Master
Partner - Master

Hi,

so do it in Qlik like in Excel:

Counts:

load

ID,

Date,

rowno() as Row      // each line becomes a number

resident YourData

order by ID, Date;  // ordered by ID and Date

left join (Counts) load 

ID,

min(Row) as MinRow   // calculate the first row of each ID

resident Counts group by ID;

Data:

load

ID,

Date,

Row-MinRow+1 as Count   /7 actual row - minimum line of each ID

resident Counts;

drop table Counts

Jo94
Contributor II
Contributor II
Author

Thank you really much for your answer, martinpohl. I'm not enabled to edit the script of my app, but I could ask the IT to do it for me. Do you know if there is a way to do this whitout editing the script? Thank you.