cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Zingoo
Frequent Visitor

Make a Shift Work Calendar

Hi. I'm making Shift Work calendar in powerapps.(4 groups 3 shift - A, B, C, D)

but I met a problem...

 

I want to make it like under picture.

Zingoo_0-1642237014133.png  >>>> Zingoo_1-1642237788368.png

 

 

Our Shift work order is Morning 3 days > rest 1 day > Swing 3 days > rest 1 day > Night 3 days > rest 1day .....

ex). 2022-01-01 - Morning : 'D group', Swing : 'A group', Night : 'C group'

       2022-01-02 - Morning : 'D group', Swing : 'A group', Night : 'B group' 

       2022-01-03 - Morning: 'D group', Swing : 'C group', Night : 'B group' .................

 

please help.. T-T..

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Zingoo :

According to your requirements, the schedule should be a cycle of 12 days.So the first step, I will first construct an auxiliary table as the basis for the loop.

ClearCollect(
  ALoop,
 {NO:1,Morning:"D",Swing:"B",Night:"C"},
 {NO:2,Morning:"D",Swing:"A",Night:"C"},
 {NO:3,Morning:"D",Swing:"A",Night:"B"},
 {NO:4,Morning:"C",Swing:"A",Night:"B"},
 {NO:5,Morning:"C",Swing:"D",Night:"B"},
 {NO:6,Morning:"C",Swing:"D",Night:"A"},
 {NO:7,Morning:"B",Swing:"D",Night:"A"},
 {NO:8,Morning:"B",Swing:"C",Night:"A"},
 {NO:9,Morning:"B",Swing:"C",Night:"D"},
 {NO:10,Morning:"A",Swing:"C",Night:"D"},
 {NO:11,Morning:"A",Swing:"B",Night:"D"},
 {NO:0,Morning:"A",Swing:"B",Night:"C"}
)

Next, use this formula to get the schedule for the whole year of 2022:

ForAll(
    Sequence(365,1,1),
    With(
        {TheRecord:LookUp(ALoop,NO=Mod(Value,12))},
        {
            Date:DateAdd(Date(2022,1,1),Value-1,Days),
            Morning:TheRecord.Morning,
            Swing:TheRecord.Swing,
            Night:TheRecord.Night
        }
    )
)

vbofengmsft_0-1642472788774.png

Best Regards,

Bof

 

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @Zingoo :

According to your requirements, the schedule should be a cycle of 12 days.So the first step, I will first construct an auxiliary table as the basis for the loop.

ClearCollect(
  ALoop,
 {NO:1,Morning:"D",Swing:"B",Night:"C"},
 {NO:2,Morning:"D",Swing:"A",Night:"C"},
 {NO:3,Morning:"D",Swing:"A",Night:"B"},
 {NO:4,Morning:"C",Swing:"A",Night:"B"},
 {NO:5,Morning:"C",Swing:"D",Night:"B"},
 {NO:6,Morning:"C",Swing:"D",Night:"A"},
 {NO:7,Morning:"B",Swing:"D",Night:"A"},
 {NO:8,Morning:"B",Swing:"C",Night:"A"},
 {NO:9,Morning:"B",Swing:"C",Night:"D"},
 {NO:10,Morning:"A",Swing:"C",Night:"D"},
 {NO:11,Morning:"A",Swing:"B",Night:"D"},
 {NO:0,Morning:"A",Swing:"B",Night:"C"}
)

Next, use this formula to get the schedule for the whole year of 2022:

ForAll(
    Sequence(365,1,1),
    With(
        {TheRecord:LookUp(ALoop,NO=Mod(Value,12))},
        {
            Date:DateAdd(Date(2022,1,1),Value-1,Days),
            Morning:TheRecord.Morning,
            Swing:TheRecord.Swing,
            Night:TheRecord.Night
        }
    )
)

vbofengmsft_0-1642472788774.png

Best Regards,

Bof

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,792)