@Kevin00
ForAll always returns a table...always!
Please consider changing your Formula to the following:
With({
_compDate:
Switch(ddlAlertsDateFilter.Selected.Value,
"24 Hrs", DateAdd(Now(), -1, Days),
"4 Hrs", DateAdd(Now(), -4, Hours),
"8 Hrs", DateAdd(Now(), -8, Hours),
"3 Days", DateAdd(Now(), -3, Days),
"7 Days", DateAdd(Now(), -7, Days)
),
},
With({_data:
SortByColumns(
Filter(collEmailAlerts,
!IsBlank(EmailDateTime) &&
EmailDateTime > _compDate
),
"EmailDateTime", Descending
)
},
ForAll(
Sequence(CountRows(_data), Patch(Last(FirstN(_data, Value)), {rowNumber: Value}))
)
)
)
That should give you what you are looking for.
In the above formula, the ForAll returns the table that you need for your gallery with all of the columns of your data from the filter and the added column of the rowNumber.
Note, it does this with the table in _data - which is the table returned from the filter AND (importantly) is the sorted table. This way your row numbers are always accurate.
Ideally, you should consider changing the Items property of the ddlAlertsDateFilter to:
Table(
{Value: "24 Hrs", compDate: DateAdd(Today(), -1, Days)},
{Value: "4 Hrs", compDate: DateAdd(Today(), -4, Hours)},
{Value: "8 Hrs", compDate: DateAdd(Today(), -8, Hours)},
{Value: "3 Days", compDate: DateAdd(Today(), -3, Days)},
{Value: "7 Days", compDate: DateAdd(Today(), -7, Days)}
)
Then your Gallery Items property would be the following:
With({_data:
SortByColumns(
Filter(collEmailAlerts,
!IsBlank(EmailDateTime) &&
EmailDateTime > ddlAlertsDateFilter.Selected.compDate
),
"EmailDateTime", Descending
)
},
ForAll(
Sequence(CountRows(_data), Patch(Last(FirstN(_data, Value)), {rowNumber: Value}))
)
)
I have a video on the subject of alternating row colors that might also be of interest to you.
I hope this is helpful for you.