I'm having an issue with my gallery that filtering appears to be not working until I interact with all my combo-box filter items at least once.
When my app loads, I can see all gallery items as I would expect. But the moment I interact with any of the above filters, the gallery appears empty.
The gallery will remain empty until I select a value with all 3 combo-boxes, which will then cause the gallery to populate based on the selected filters.
If I then clear the filters, the gallery will now populate as expected according to which ever filters I select, even if I only filter using one or two combo-boxes. But they won't work until each combo box value has been changed once.
This could be problematic if users attempt to filter for themselves as owners and see nothing in the gallery that requires their action. I'd like the filters to work as intended immediately as the app starts.
At first I thought the InputTextPlaceholder property of the combo boxes could be causing the value of the combo box to be causing the value to be changed, but even after clearing this, it still doesn't work as intended.
Below I've noted the formula I'm using in the Items property of my gallery.
If (
//trying everything to ensure gallery is unfiltered if no filters are selected
((IsEmpty(StatusCombo.SelectedItems) || IsBlank(StatusCombo.SelectedItems) || CountRows(StatusCombo.SelectedItems) = 0) &&
(IsEmpty(OwnerCombo.SelectedItems) || IsBlank(OwnerCombo.SelectedItems) || CountRows(OwnerCombo.SelectedItems) = 0) &&
(IsEmpty(DateCombo.SelectedItems) || IsBlank(DateCombo.SelectedItems) || CountRows(DateCombo.SelectedItems) = 0) &&
(IsBlank(RequestSearchText.Text) || RequestSearchText.Text = "")
),
//if no filters are selected, list items in order based on SortDescending1
SortByColumns(
'Surv_3PR_RequestList',
"Created",
If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
),
//else sort by filters
SortByColumns(
With(
{
//get filters
filterStatus: StatusCombo.SelectedItems,
filterOwner: OwnerCombo.SelectedItems,
rangeLabel: If(
IsBlank(DateCombo.Selected),
"",
Coalesce(DateCombo.Selected.Label, "")
)
},
With(
{
//get date bounds from the label
startDate:
Switch(
rangeLabel,
"Last 7 Days", DateAdd(Today(), -6, TimeUnit.Days),
"Last 14 Days", DateAdd(Today(), -13, TimeUnit.Days),
"Last 30 Days", DateAdd(Today(), -29, TimeUnit.Days),
"Last 90 Days", DateAdd(Today(), -89, TimeUnit.Days),
"This Year", Date(Year(Today()), 1, 1),
"Last Year", Date(Year(Today()) - 1, 1, 1),
Blank()
),
endDate:
Switch(
rangeLabel,
"Last 7 Days", Today(),
"Last 14 Days", Today(),
"Last 30 Days", Today(),
"Last 90 Days", Today(),
"This Year", Today(),
"Last Year", Date(Year(Today()) - 1, 12, 31),
Blank()
),
//normalize the search text once
searchTxt: Lower(Trim(Coalesce(RequestSearchText.Text, "")))
},
Filter(
Surv_3PR_RequestList,
// filter by status (multi-select)
IsEmpty(filterStatus) || CountIf(filterStatus, Value = RequestStatus.Value) > 0,
// filter by owner
IsEmpty(filterOwner) || CountIf(filterOwner, DisplayName = RequestOwner) > 0,
//filter by date range
IsBlank(startDate) || Created >= DateTimeValue(startDate),
IsBlank(endDate) || Created < DateAdd(DateTimeValue(endDate), 1, TimeUnit.Days),
// filter by substring search across RequestorName and OffenderDetails
IsBlank(searchTxt) ||
Find(
searchTxt,
Lower(Coalesce(RequestorName, ""))
) > 0 ||
Find(
searchTxt,
Lower(Coalesce(OffenderDetails, ""))
) > 0 ||
Find(
searchTxt,
Lower(Coalesce(Title, ""))
) > 0
)
)
),
"Created",
If(SortDescending1, SortOrder.Descending, SortOrder.Ascending)
)
)