
Hi,
After much troubleshooting, research and YouTube videos, I am unable to resolve an issue with my gallery. Simply put, the gallery is filtered using a search box and comboboxes with multiple selections. When loading the app, the gallery is blank until I select and then deselect an item in each combobox, then the gallery and filtering works fine.
I am not overly experienced with PowerApps, however based on a lot of searching and Reza's video's, I pieced together the following code:
Filter(
DataSource,
StartsWith(
Title,
ListSearch.Text
)
&& (IsBlank(ComboBox1.Selected.Value) || IsEmpty(ComboBox1.SelectedItems) || Column1 in ComboBox1.SelectedItems),
If(IsBlank(ComboBox2.Selected.Value),IsEmpty(ComboBox2.SelectedItems),"yes" in ForAll(ComboBox2.SelectedItems,If(Value in Column2.Value,"yes","no"))),
If(IsBlank(ComboBox3.Selected.Value),IsEmpty(ComboBox3.SelectedItems),"yes" in ForAll(ComboBox3.SelectedItems,If(Value in Column3.Value,"yes","no"))),
If(IsBlank(ComboBox4.Selected.Value),IsEmpty(ComboBox4.SelectedItems),"yes" in ForAll(ComboBox4.SelectedItems,If(Value in Column4.Value,"yes","no"))),
If( IsEmpty(ComboBox5.SelectedItems),IsBlank(ComboBox5.Selected.Value),"yes" in ForAll(ComboBox5.SelectedItems,If(Value in Column5.Value,"yes","no")))
)
As mentioned, this does allow the gallery to be filtered, but only after I select an item and then deselect it in ComboBoxes 2-5.
For context, ComboBox1 is linked to a choice column with a single-selected item, ComboBox2, 3, 4 & 5 are linked to a choice column with multiple selections. Every ComboBox Items is set to the following, where "RelevantColumn" is either columns 1-5 depending on the ComboBox:
Choices(DataSource.RelevantColumn)
I have been scratching my head on what the issue is, it appears IsBlank is producing an error similar to what someone else reported - IsBlank gave a value of "False" when starting the app, when it should be "True" (Solved: Unselected combobox shows false in isEmpty - Power Platform Community (microsoft.com)). Unfortunately the solution in that thread does not work for me as it only allows ComboBox.Selected.Value or ComboBox.SelectedItems to be entered into the code. Their solution was:
IsBlank(Combobox.Selected.ColumnName)
Default on the gallery and ComboBoxes is set to "Blank()", the DefaultSelectedItems on them is empty.
Edit to add - the ComboBoxes work fine and the gallery filters as expected after I do the select/deselect method mentioned above. The IsBlank also displays as "True" after doing this, hence why everything works after.
Any help would be greatly appreciated. Thanks in advance
From further research it appears the IsEmpty relates to the contents within the source table rather than the ComboBox being empty (although I am not 100% sure).
I cannot explain how or why, but by removing the IsEmpty and initial If statements and amending the code to the following, the below appears to have fixed the issue:
Filter(
DataSource,
StartsWith(
Title,
ListSearch.Text
)
&& (IsBlank(ComboBox1.Selected.Value) || IsEmpty(ComboBox1.SelectedItems) || Column1 in ComboBox1.SelectedItems),
(IsBlank(ComboBox2.Selected.Value) || "yes" in ForAll(ComboBox2.SelectedItems,If(Value in Column2.Value,"yes","no"))),
(IsBlank(ComboBox3.Selected.Value) || "yes" in ForAll(ComboBox3.SelectedItems,If(Value in Column3.Value,"yes","no"))),
(IsBlank(ComboBox4.Selected.Value) || "yes" in ForAll(ComboBox4.SelectedItems,If(Value in Column4.Value,"yes","no"))),
IsEmpty(ComboBox5.SelectedItems) || "yes" in ForAll(ComboBox5.SelectedItems,If(Value in Column5.Value,"yes","no")))
)