cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sal27562
Level: Powered On

dropdown blank value to view all records in a gallery filter.

Using the  following for a gallery item ... Filter (TableName, StartsWith( TableColumn, Dropdown1) .

 

Using a dropdown(1) box with the following items ["","Blue","Green"], when it first initialises I see all records including values "Blue" and "Green" in a gallery (which makes sense). When I click on "Blue" from the dropdown I get all records with the value "Blue" (which makes sense). However, when I then click to the first selection in the dropdown "", I do not see all records again, Instead I see no records. Is this a bug because it works fine if I use a text input box instead of a dropdown box and follow the same string sequence?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: dropdown blank value to view all records in a gallery filter.

You can also use an Or operator to have a filter expression without using context variables:

 

Filter(
    TableName,
    Dropdown1.Selected.Value = "All" Or StartsWith(Column1, Dropdown1.Selected.Value),
    Dropdown2.Selected.Value = "All" Or StartsWith(Column2, Dropdown2.Selected.Value),
    Dropdown3.Selected.Value = "All" Or StartsWith(Column3, Dropdown3.Selected.Value),
    Dropdown4.Selected.Value = "All" Or StartsWith(Column4, Dropdown4.Selected.Value))

If all dropdown are set to 'All', then all filter expressions will evaluate to true and all records from the table (SP list) will be displayed in the gallery.

9 REPLIES 9
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: dropdown blank value to view all records in a gallery filter.

You can try to be more specific with the filter expression (to choose the dropdown selected item), maybe this will work:

Filter(TableName, StartsWith(TableColumn, Dropdown1.Selected.Value))
sal27562
Level: Powered On

Re: dropdown blank value to view all records in a gallery filter.

Thanks for your reply Carlos.

 

Yes I am using the Dropdown1.Selected.Value within the filter expression already.

 

The TableName is a name of a list in SharePoint I am connected to, and likewise the TableColumn is a column in the list.

 

If the dropdown1 box has 'blue' selected then only records that have the word 'blue' in the list are returned to the gallery. This works as it should. But when I then change the value of the selected item in dropdown1 to the default value "" (blank) i do not see all the records from the list.

 

If I use TextInput1.Text instead of Dropdown1.Selected.Value in the filter and use a textbox instead of a dropdown I get the desired result but I just cannot get it working with Dropdown1.Selected.Value.

sal27562
Level: Powered On

Re: dropdown blank value to view all records in a gallery filter.

I assume there is a difference in format type between the default value of the dropdown1 box which is "" and works within the filter, to the selected value which is "" in the dropdown1 box that doesnt work with the filter. I have also tried using value of the dropdown box to [Text(""),"Blue","Green"] without any joy either.

 

 

Super User
Super User

Re: dropdown blank value to view all records in a gallery filter.

You could try changing the "" value to "All" then updating the filter formula with an "If" statement.

 

IF(Dropdown1.Selected.Value = "All", TableName,
  Filter(TableName, StartsWith(TableColumn, Dropdown1.Selected.Value)
  )
)


--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
sal27562
Level: Powered On

Re: dropdown blank value to view all records in a gallery filter.

Thanks Jeff for the response,

I kept the example I gave very simple as to establish why the dropdown and filter relationship does not work correctly.

 

I actually aim to build up the gallery filter using several dropdowns (8+) related to several columns in my table so using IF and the "all" value you suggest would become very complex. I was hoping the startwith function would be the easiest and best solution.

 

How could the IF method be used for the following scenario:

Dropdown1 = ["All","Blue","Green"] (this is pointing to the 'colour' column of the source table.)

Dropdown2 = ["All","Hat","Coat","Trousers"] (this is pointing to the 'clothing_type' column of the source table.)

Dropdown3 = ["All","Small","Medium","Large"] (this is pointing to the 'size' column of the source table.)

 

If Dropdown1 = "All" and Dropdown2 = "Hat" and Dropdown3 = "Medium" then the gallery would show all "Medium" sized "Hats" in every colour.

sal27562
Level: Powered On

Re: dropdown blank value to view all records in a gallery filter.

Ok I found a work around until Powerapps sort out the bug between the dropdown "" value and filter of a gallery showing all records.

 

I have created a button to use with the dropdowns. OnSelect of the button it creates a context variable with the below script:

 

If(Dropdown1.Selected.Value = "All",UpdateContext({test1:""}),UpdateContext({test1: Dropdown1.Selected.Value}));
If(Dropdown2.Selected.Value = "All",UpdateContext({test2:""}),UpdateContext({test2: Dropdown2.Selected.Value}));

If(Dropdown3.Selected.Value = "All",UpdateContext({test3:""}),UpdateContext({test3: Dropdown3.Selected.Value}))

 

My gallery item now has the following filter:

 

Filter(TableName,StartsWith(TableColumn1,test1),StartsWith(TableColumn2,test2),StartsWith(TableColumn3,test3)).

 

These seems to work, so if the Context variable test(n) = "" then the gallery shows all records.

 

Finally, a solution I can work with.

Highlighted
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: dropdown blank value to view all records in a gallery filter.

You can also use an Or operator to have a filter expression without using context variables:

 

Filter(
    TableName,
    Dropdown1.Selected.Value = "All" Or StartsWith(Column1, Dropdown1.Selected.Value),
    Dropdown2.Selected.Value = "All" Or StartsWith(Column2, Dropdown2.Selected.Value),
    Dropdown3.Selected.Value = "All" Or StartsWith(Column3, Dropdown3.Selected.Value),
    Dropdown4.Selected.Value = "All" Or StartsWith(Column4, Dropdown4.Selected.Value))

If all dropdown are set to 'All', then all filter expressions will evaluate to true and all records from the table (SP list) will be displayed in the gallery.

sal27562
Level: Powered On

Re: dropdown blank value to view all records in a gallery filter.

Thanks Carlos,

 

That is a great alternative method.

alex3
Level: Powered On

Re: dropdown blank value to view all records in a gallery filter.

Hi @CarlosFigueira

 

How does the "All" works in this case. I cant get it to work. It selects the options of the dropdown, but I cant get it to select all options if none are selected. Smiley Sad

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 88 members 4,178 guests
Please welcome our newest community members: