I am using the Sequence function in a formula to calculate elapsed time between dates, excluding weekends and holidays. My data source is date columns in a SharePoint list. When I play the app, it immediately displays an error, "The first argument to Sequence must be between 0 and 50,000." When I complete the form and click Submit, the error returns. The form works perfectly despite the error, and updates the SharePoint list correctly.
I also see the error when I open the app to edit.
The formula is in the default property of a text control in a form with data cards.
Here is the formula:
With(
{
// generate a one-column table of all dates between start date & end date
varDateRange: ForAll(
Sequence(DecisionDateValue1.SelectedDate - RequestDateValue2.SelectedDate + 1),
RequestDateValue2.SelectedDate + Value - 1
)
},
If(
And(
IsBlank(RequestDateValue2.SelectedDate),
IsBlank(DecisionDateValue1.SelectedDate)
),
// show nothing if any date pickers are blank
0,
// include only dates Monday to Friday
CountIf(
varDateRange,
And(
Weekday(Value) in [2, 3, 4, 5, 6],
Not(Value in 'Holidays Calendar'.HolidayDay)
)
)
)
)
DecisionDateValue1 and RequestDateValue2 are date pickers (date columns in SharePoint).
When I highlight Sequence(DecisionDateValue1.SelectedDate - RequestDateValue2.SelectedDate + 1) in the editor, I can see that the values are correct and that the value is always between 0 and 50,000.
Why am I getting this error and how can I get rid of it?