Displaying Previous Current Next 2 Weeks in Power Apps Combo Box

Steps to Display Previous 2 Weeks, Current Week, and Next 2 Weeks in a ComboBox in Power Apps

  1. Set the Current Date
    • Create a variable vToday to hold the current date.
      Set

This table lists five date ranges, each representing a week, with start and end dates derived from the current date (vToday). Here’s a breakdown of the script.

  1. First Date Range
    • Value: The range from 13 days before the start of the current week to 7 days before the start of the current week.
    • stDate: The start date of this range.
    • lDate: The end date of this range.
  2. Second Date Range
    • Value: The range from 6 days before the start of the current week to the end of the previous week.
    • stDate: The start date of this range.
    • lDate: The end date of this range.
  3. Third Date Range
    • Value: The range from the first day of the current week to the last day of the current week.
    • stDate: The start date of this range.
    • lDate: The end date of this range.
  4. Fourth Date Range
    • Value: The range from the first day of the next week to the last day of the next week.
    • stDate: The start date of this range.
    • lDate: The end date of this range.
  5. Fifth Date Range
    • Value: The range from the first day of the week after the next week to the last day of the week after the next week.
    • stDate: The start date of this range.
    • lDate: The end date of this range.

Write FX  On Items Property of Combobox

Table(
    {
        Value: Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) - 13,
            "mm/dd/yyyy"
        ) & " - " & Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) - 7,
            "mm/dd/yyyy"
        ),
        stDate: Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) - 13,
            "mm/dd/yyyy"
        ),
        lDate: Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) - 7,
            "mm/dd/yyyy"
        )
    },
    {
        Value: Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) - 6,
            "mm/dd/yyyy"
        ) & " - " & Text(
            vToday + 7 - Weekday(vToday, StartOfWeek.Monday) - 7,
            "mm/dd/yyyy"
        ),
        stDate: Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) - 6,
            "mm/dd/yyyy"
        ),
        lDate: Text(
            vToday + 7 - Weekday(vToday, StartOfWeek.Monday) - 7,
            "mm/dd/yyyy"
        )
    },
    {
        Value: Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) + 1,
            "mm/dd/yyyy"
        ) & " - " & Text(
            vToday + (7 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        ),
        stDate: Text(
            vToday - Weekday(vToday, StartOfWeek.Monday) + 1,
            "mm/dd/yyyy"
        ),
        lDate: Text(
            vToday + (7 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        )
    },
    {
        Value: Text(
            vToday + (8 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        ) & " - " & Text(
            vToday + (14 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        ),
        stDate: Text(
            vToday + (8 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        ),
        lDate: Text(
            vToday + (14 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        )
    },
    {
        Value: Text(
            vToday + (15 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        ) & " - " & Text(
            vToday + (21 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        ),
        stDate: Text(
            vToday + (15 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        ),
        lDate: Text(
            vToday + (21 - Weekday(vToday, StartOfWeek.Monday)),
            "mm/dd/yyyy"
        )
    }
)

  


Similar Articles