Steps to Display Previous 2 Weeks, Current Week, and Next 2 Weeks in a ComboBox in Power Apps
- Set the Current Date
- Create a variable vToday to hold the current date.
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.
- 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.
- 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.
- 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.
- 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.
- 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"
)
}
)