Hi All,
Good day.

I am trying to develop a roster for my team in Microsoft Power Apps. We are 6 teammates which do the duty in following format.
SUMMERS:
6A, 6B, 11A, 11B, 12A, 12B

WINTERS:
7A, 7B, 11A, 11B, 1A, 1B.

Please note that in every shift there are two persons so we use A and B for each person. This is just to identify which person from which shift will be working from home and who will be working from office. The A and B decides that.

If a person is doing a shift of 6A this week, then he will have the following format next weeks. 6A -> 11A -> 12A ->6B ->11B ->12B OR 7A ->11A -> 1A ->7B ->11B ->1B

11A will have Friday Off and Sunday on as 8A.

What I have achieves so far is that I can select start date from DatePicker1 and end date from DatePicker2. Select Time slots from DropDown lists Dd1 to Dd6) and then data table Dt1 shows that time against 6 agents like
Values of Dd1 against Agent1, Dd2 against Agent2 and so on till Vale of Dd6 against Agnet6.
The table format is shown in the image attached.

I am having problem that how I can achieve the shuffling which I described above?
For example I have 30 days roster, Then how I will achieve that my table can select and show values from the DropDown lists for the first week only and then shuffles the next 3 weeks as the logic shared above.

The code I used.

// Step 1: Set the start date and end date
Set(startDate, DatePicker1.SelectedDate);
Set(endDate, DatePicker2.SelectedDate);

// Step 2: Calculate the date range between startDate and endDate
ClearCollect(
    RosterData,
    { AgentName: Label1.Text, ShiftTiming: Text(Dd1.Selected.Value) },
    { AgentName: Label2.Text, ShiftTiming: Text(Dd2.Selected.Value) },
    { AgentName: Label3.Text, ShiftTiming: Text(Dd3.Selected.Value) },
    { AgentName: Label4.Text, ShiftTiming: Text(Dd4.Selected.Value) },
    { AgentName: Label5.Text, ShiftTiming: Text(Dd5.Selected.Value) },
    { AgentName: Label6.Text, ShiftTiming: Text(Dd6.Selected.Value) }
);

ClearCollect(
    DateRange,
    AddColumns(
        Filter(
            AddColumns(
                Sequence(
                    DateDiff(startDate, endDate) + 1
                ),
                Date, DateAdd(startDate - 1, Value) 
            ),
            Weekday(Date, StartOfWeek.Monday) >= 1,  // Include all days of the week
            Weekday(Date, StartOfWeek.Monday) <= 7   // Include all days of the week
        ),
        Day, Text(Date, "[$-en-US]ddd")
    )
);

// Step 3: Generate the monthly roster
ClearCollect(
    MonthlyRoster,
    AddColumns(
        DateRange,
        Agent1,
        If(
            Dd1.Selected.Value = "11A" && Day = "Fri", "Off",
            If(
                Dd1.Selected.Value = "11A" && Day = "Sun", "8A",
                If(Day = "Sat" || Day = "Sun", "Off", Dd1.Selected.Value)
            )
        ),
        Agent2,
        If(
            Dd2.Selected.Value = "11A" && Day = "Fri", "Off",
            If(
                Dd2.Selected.Value = "11A" && Day = "Sun", "8A",
                If(Day = "Sat" || Day = "Sun", "Off", Dd2.Selected.Value)
            )
        ),
        Agent3,
        If(
            Dd3.Selected.Value = "11A" && Day = "Fri", "Off",
            If(
                Dd3.Selected.Value = "11A" && Day = "Sun", "8A",
                If(Day = "Sat" || Day = "Sun", "Off", Dd3.Selected.Value)
            )
        ),
        Agent4,
        If(
            Dd4.Selected.Value = "11A" && Day = "Fri", "Off",
            If(
                Dd4.Selected.Value = "11A" && Day = "Sun", "8A",
                If(Day = "Sat" || Day = "Sun", "Off", Dd4.Selected.Value)
            )
        ),
        Agent5,
        If(
            Dd5.Selected.Value = "11A" && Day = "Fri", "Off",
            If(
                Dd5.Selected.Value = "11A" && Day = "Sun", "8A",
                If(Day = "Sat" || Day = "Sun", "Off", Dd5.Selected.Value)
            )
        ),
        Agent6,
        If(
            Dd6.Selected.Value = "11A" && Day = "Fri", "Off",
            If(
                Dd6.Selected.Value = "11A" && Day = "Sun", "8A",
                If(Day = "Sat" || Day = "Sun", "Off", Dd6.Selected.Value)
            )
        )
    )
);

// Step 4: Refresh the Data Table by reassigning the updated collection
// DT1.Items = MonthlyRoster;

BR.
AK.

Sorry. Forgot to attach the image in the main description.

ITSDRosterError.jpg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.