Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
nezuko_kamado
Creator
Creator

Combine consecutive Sat and Sun as weekend

I need to analysis on consecutive Saturday and Sunday, and want to create a new variable as weekend.

Cause when counting Saturday and Sunday, which is not consecutive, and I don't get the result. For example from my data,

Consecutive weekend has unit : 2 out of 3      VS     Weekend has unit: 5 out 6

so, how can I combine consecutive Sat and Sun as weekend at the load editor or creating variable?

10/2/2021Sat3Weekend
10/3/2021Sun5Weekend
10/9/2021Sat0Weekend
10/10/2021Sun3Weekend
10/16/2021Sat5Weekend
10/17/2021Sun1Weekend

 

data:
load * inline [Date, Weekday, Unit
10/1/2021, Fri, 2
10/2/2021, Sat, 3
10/3/2021, Sun, 5
10/4/2021, Mon, 6
10/5/2021, Tue, 1
10/6/2021, Wed, 2
10/7/2021, Thu, 3
10/8/2021, Fri, 2
10/9/2021, Sat, 0
10/10/2021, Sun, 3
10/11/2021, Mon, 2
10/12/2021, Tue, 1
10/13/2021, Wed, 3
10/14/2021, Thu, 4
10/15/2021, Fri, 5
10/16/2021, Sat, 5
10/17/2021, Sun, 1
10/18/2021, Mon, 2
10/19/2021, Tue, 3
10/20/2021, Wed, 1]

Labels (3)
1 Reply
joaopaulo_delco
Partner - Creator III
Partner - Creator III

Hi @nezuko_kamado !

I think you can try this:

data:
Load
    Date, 
    Weekday, 
    if(Match(Weekday,'Sat','Sun'),'Weekend',Weekday) as Weekday2,
    Unit;
Load * inline [Date, Weekday, Unit
10/1/2021, Fri, 2
10/2/2021, Sat, 3
10/3/2021, Sun, 5
10/4/2021, Mon, 6
10/5/2021, Tue, 1
10/6/2021, Wed, 2
10/7/2021, Thu, 3
10/8/2021, Fri, 2
10/9/2021, Sat, 0
10/10/2021, Sun, 3
10/11/2021, Mon, 2
10/12/2021, Tue, 1
10/13/2021, Wed, 3
10/14/2021, Thu, 4
10/15/2021, Fri, 5
10/16/2021, Sat, 5
10/17/2021, Sun, 1
10/18/2021, Mon, 2
10/19/2021, Tue, 3
10/20/2021, Wed, 1];
Help users find answers! Don't forget to mark a solution that worked for you!