Hello,
I have a problem where a Gallery Items formula isn't working when I try to filter by building or date. I have a very similar formula working just fine for a different application, but it won't work here.
The formula works in this entry log app when the building and date filters are empty.

However, once I put in a building or date filter, nothing shows up and I get this error saying the query is invalid.


Strangely enough, I initially copied the query from this other application where it does work when I filter by date or building:

Here's the formula on the entry log application where it isn't working:
If(IsNumeric(Value(TextInput10.Text)),
//If search is for a room number
If(
//If a date is not selected and a building is not selected.
IsBlank(DatePicker8.SelectedDate) && IsBlank(ComboBox1.Selected.Result),
Filter(SortByColumns('Entry & Exit Logs', "Created", Descending), (Room >= Value(TextInput10.Text) And Room < Value(TextInput10.Text)+1) Or (Room >= 10*Value(TextInput10.Text) And Room < 10*(1+Value(TextInput10.Text))) Or (Room >= 100*Value(TextInput10.Text) And Room < 100*(1+Value(TextInput10.Text)))),
//If a date is selected and a building is not selected.
Not(IsBlank(DatePicker8.SelectedDate)) && IsBlank(ComboBox1.Selected.Result),
Filter(Filter(SortByColumns('Entry & Exit Logs', "Created", Descending), Created >= DatePicker8.SelectedDate And Created < DateAdd(DatePicker8.SelectedDate, 1, Days)), (Room >= Value(TextInput10.Text) And Room < Value(TextInput10.Text)+1) Or (Room >= 10*Value(TextInput10.Text) And Room < 10*(1+Value(TextInput10.Text))) Or (Room >= 100*Value(TextInput10.Text) And Room < 100*(1+Value(TextInput10.Text)))),
//If a date is not selected and a building is selected.
IsBlank(DatePicker8.SelectedDate) && Not(IsBlank(ComboBox1.Selected.Result)),
Filter(SortByColumns(Filter('Entry & Exit Logs', Bldg = ComboBox1.Selected.Result), "Created", Descending), (Room >= Value(TextInput10.Text) And Room < Value(TextInput10.Text)+1) Or (Room >= 10*Value(TextInput10.Text) And Room < 10*(1+Value(TextInput10.Text))) Or (Room >= 100*Value(TextInput10.Text) And Room < 100*(1+Value(TextInput10.Text)))),
//If a date is selected and a building is selected.
Not(IsBlank(DatePicker8.SelectedDate)) && Not(IsBlank(ComboBox1.Selected.Result)),
Filter(Filter(SortByColumns(Filter('Entry & Exit Logs', Bldg = ComboBox1.Selected.Result), "Created", Descending), Created >= DatePicker8.SelectedDate And Created < DateAdd(DatePicker8.SelectedDate, 1, Days)), (Room >= Value(TextInput10.Text) And Room < Value(TextInput10.Text)+1) Or (Room >= 10*Value(TextInput10.Text) And Room < 10*(1+Value(TextInput10.Text))) Or (Room >= 100*Value(TextInput10.Text) And Room < 100*(1+Value(TextInput10.Text))))),
//If search is not for a room number
If(
//If a date is not selected and a building is not selected.
IsBlank(DatePicker8.SelectedDate) && IsBlank(ComboBox1.Selected.Result),
Filter(SortByColumns('Entry & Exit Logs', "Created", Descending), StartsWith(FirstName, TextInput10.Text) Or StartsWith(LastName, TextInput10.Text)),
//If a date is selected and a building is not selected.
Not(IsBlank(DatePicker8.SelectedDate)) && IsBlank(ComboBox1.Selected.Result),
Filter(Filter(SortByColumns('Entry & Exit Logs', "Created", Descending), Created >= DatePicker8.SelectedDate And Created < DateAdd(DatePicker8.SelectedDate, 1, Days)), StartsWith(FirstName, TextInput10.Text) Or StartsWith(LastName, TextInput10.Text)),
//If a date is not selected and a building is selected.
IsBlank(DatePicker8.SelectedDate) && Not(IsBlank(ComboBox1.Selected.Result)),
Filter(SortByColumns(Filter('Entry & Exit Logs', Bldg = ComboBox1.Selected.Result), "Created", Descending), StartsWith(FirstName, TextInput10.Text) Or StartsWith(LastName, TextInput10.Text)),
//If a date is selected and a building is selected.
Not(IsBlank(DatePicker8.SelectedDate)) && Not(IsBlank(ComboBox1.Selected.Result)),
Filter(Filter(SortByColumns(Filter('Entry & Exit Logs', Bldg = ComboBox1.Selected.Result), "Created", Descending), Created >= DatePicker8.SelectedDate And Created < DateAdd(DatePicker8.SelectedDate, 1, Days)), StartsWith(FirstName, TextInput10.Text) Or StartsWith(LastName, TextInput10.Text))))
The only change I made from the working medication application to the not working entry log application, is I switched out the Search functions with Filter & StartsWith functions so I could make everything delegable. But I'm not having any problem with searching by name or room in the not working entry log application, I'm only having issues filtering by building or date.
Maybe there's some issue with the query now that it's trying to delegate everything to SharePoint instead of pulling records in first? Or maybe it's something else.
Is anyone familiar with similar issues?