Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
ninawang99
Contributor
Contributor

Identify consecutive dates when give a series of dates

Hi All,

I got issue to check the number of consecutive dates.

In my dataset, Name and [Leave Date] are dimensions

ninawang99_0-1678348027058.png

the result should be like

Name Blocks
John 2
Kerry 2

 

Thanks in advance!

 

 

 

 

 

 

 

Labels (5)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

as below

 

IN Charts use

Dimension:  Name

Expression = Count(Distinct blockKey) 

 

temp:
load  Name,date(date#(Date,'DD/MM/YYYY')) as edate inline [
Name,Date
ABC,02/03/2023
ABC,03/03/2023
ABC,04/03/2023
ABC,05/03/2023
ABC,06/03/2023
ABC,07/03/2023
ABC,08/03/2023
ABC,09/03/2023
ABC,05/04/2023
ABC,06/04/2023
ABC,07/04/2023
ABC,08/04/2023
ABC,09/04/2023
];

Main:
load Name,edate,if(Name=Peek('Name'),if((edate-peek('edate'))=1,peek('blockKey'),Name&edate),Name&edate) as blockKey
Resident temp
ORder by Name,edate ASC;
drop table temp;
exit Script;

 

 

In

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

3 Replies
vinieme12
Champion III
Champion III

as below

 

IN Charts use

Dimension:  Name

Expression = Count(Distinct blockKey) 

 

temp:
load  Name,date(date#(Date,'DD/MM/YYYY')) as edate inline [
Name,Date
ABC,02/03/2023
ABC,03/03/2023
ABC,04/03/2023
ABC,05/03/2023
ABC,06/03/2023
ABC,07/03/2023
ABC,08/03/2023
ABC,09/03/2023
ABC,05/04/2023
ABC,06/04/2023
ABC,07/04/2023
ABC,08/04/2023
ABC,09/04/2023
];

Main:
load Name,edate,if(Name=Peek('Name'),if((edate-peek('edate'))=1,peek('blockKey'),Name&edate),Name&edate) as blockKey
Resident temp
ORder by Name,edate ASC;
drop table temp;
exit Script;

 

 

In

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
ninawang99
Contributor
Contributor
Author

It worked! Appreciate!!!

vinieme12
Champion III
Champion III

👍, please mark it as a solution and close the thread

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.