Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
eladberko
Contributor II
Contributor II

find the next work day

Hi,

i have a dates list and employment ratio for each day loaded in script.

i need to find the next working day [next_active_day] when the [employment_ratio] is set 0.

i managed when the gap is about one day only , but when the gap is more then one day i'm lost (for exp the 5/4/23).

appreciate any help.

thanks.

 

eladberko_1-1683645559842.png

 

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda

@eladberko  try below

Data:
Load * Inline [
Date, employment_ratio
01/04/2023,0
02/04/2023,1
03/04/2023,1
04/04/2023,1
05/04/2023,0
06/04/2023,0
07/04/2023,0
08/04/2023,0
09/04/2023,0.5
10/04/2023,0.5
11/04/2023,0.25
12/04/2023,0
13/04/2023,1 ];

New:
Load *,
      if(RowNo()=1 or employment_ratio<>0,Date,
      if(employment_ratio=0 and Previous(employment_ratio)<>0, Previous(Date),     
     if(employment_ratio=0 and Previous(employment_ratio)=0,Peek('next_active_day')))) as next_active_day
Resident Data
Order by Date desc;

Drop Table Data;

Screenshot 2023-05-10 215006.png

View solution in original post

4 Replies
Chanty4u
MVP
MVP

May be this 

=Min({<Employment_Ratio={0}, Date={">$(=Max(Date))"}>} Date)

 

eladberko
Contributor II
Contributor II
Author

thank you, but i need the solution in script loader.

Kushal_Chawda

@eladberko  try below

Data:
Load * Inline [
Date, employment_ratio
01/04/2023,0
02/04/2023,1
03/04/2023,1
04/04/2023,1
05/04/2023,0
06/04/2023,0
07/04/2023,0
08/04/2023,0
09/04/2023,0.5
10/04/2023,0.5
11/04/2023,0.25
12/04/2023,0
13/04/2023,1 ];

New:
Load *,
      if(RowNo()=1 or employment_ratio<>0,Date,
      if(employment_ratio=0 and Previous(employment_ratio)<>0, Previous(Date),     
     if(employment_ratio=0 and Previous(employment_ratio)=0,Peek('next_active_day')))) as next_active_day
Resident Data
Order by Date desc;

Drop Table Data;

Screenshot 2023-05-10 215006.png

eladberko
Contributor II
Contributor II
Author

perfect. thank you!