Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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/2021 | Sat | 3 | Weekend |
10/3/2021 | Sun | 5 | Weekend |
10/9/2021 | Sat | 0 | Weekend |
10/10/2021 | Sun | 3 | Weekend |
10/16/2021 | Sat | 5 | Weekend |
10/17/2021 | Sun | 1 | Weekend |
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]
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];