Set default value as null or blank for drop-down in PowerApps


Posted By : Rakesh Pandey

Added :

11 Comments


In our previous blog, we saw how to create a cascading dropdown in PowerApps using the SharePoint custom list as data source. Today we will see how to set the default value as null or blank for drop-down in PowerApps. We will use the same “States” SharePoint custom list in order to demonstrate this. We have used the “ClearCollect” and “Collect” PowerApps formula to set the default value as null or blank for the drop-down list. For more details on PowerApps formulae, please refer link.

Create PowerApps Screen

In the below screen as you can see that I have created a PowerApps screen with two cascading dropdown list State and District. If you don’t know how to do the cascading please read my previous blog.

Figure 1

Setting a Default value for “State” dropdown list

In order to set the default value of State dropdown list we will use “ClearCollect(collection1,{Name:""}); Collect(collection1,Distinct(States,Title))” formula on “OnSelect ” action of “StateDropdown”. Select behavior will run when we are clicking or selecting the dropdown list. As from the above formulae, we can see that on select of state dropdown first ClearCollect will run followed by the Collect.

Under the Data section the Items for the State dropdown list will be “collection1” which was created using Collect formula. For better understanding please refer below screenshot.

Figure 2

After implementing the formula the State dropdown will look like below.

Set default value as null

Figure 3

Setting a Default value for “District” dropdown list

In order to set the default value of District dropdown list we will use “ClearCollect(collection2,{Name:""});Collect(collection2,(Filter(States,Title=StateDropdown.Selected.Result).District))” formula on “OnSelect ” action of “DsitrictDropdown”. We will use “collection2” to populate the items for District dropdown. Please refer below screenshot for the same.

Set default value as null

Figure 4

Once we are done with the formula than District dropdown will look like below.

Set default value as null

Figure 5

If there are any other ways to set the default values of the dropdown, please let us know by replying. Thanks for visiting my blog. Please share and subscribe to our site for more stuff on PowerApps. In our next blog, we will see how to create a PowerApps form for the SharePoint list.

Reference:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/formula-reference

https://powerusers.microsoft.com/t5/General-Discussion/Need-Dropdown-with-blank-null-default/td-p/58172

0 0 votes
Article Rating
Subscribe
Notify of
guest

11 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Joanne
Joanne
5 years ago

Thank you. Could I name the blank value to “Show All” instead of leave it blank?

Joanne
Joanne
5 years ago

Thanks Rakesh, it works!!

Maggie
Maggie
4 years ago

Nice Blog, really helpful…
Thank you!

Sunil Jogi E
Sunil Jogi E
3 years ago

Hi Rakesh, this has been really helpful.. i was struggling to get this done and landed in the right place i know.
ClearCollect(collection1,{Result:”Show All”}); Collect(collection1,Distinct(States,Title)) -> this works only for a state dropdown field but not with District.

if i use it in similar fashion for District field , it doesn’t show the result and returns blank value.
ClearCollect(collection2,{Result:”Show All”});Collect(collection2,(Filter(States,Title=StateDropdown.Selected.Result).District))

can you please help and suggest ?

Sunil Jogi E
Sunil Jogi E
3 years ago

Hi Rakesh,
Thanks for your response. i was trying to implement this on multi level cascading dropdowns, and i think i have figured it out. so in the above example, our formula will be: ClearCollect(collection2,{District:”Show All”});Collect(collection2,(Filter(States,Title=StateDropdown.Selected.Result).District)).
passing the value of drop down field will set the blank value to custom message we pass. thank you very much once again !

Brooke G
Brooke G
2 years ago

Hi Sunil,

I am having an issue once the item is submitted and a user wants to edit their form (SharePoint list item), it clears both the values in the cascading drop downs. The value is stored in the list, but doesn’t appear in the dropdowns one they go to modify. Can you assist?