+91 – 88617 28680learning@flexmind.co

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

30
Jul

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


In our previous blog we saw how to create a cascading drop down in PowerApps using SharePoint custom list as data source. Today we will see how to set 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 “ClearCollect” and “Collect” PowerApps formula to set default value as null or blank for drop down list. For more details on PowerApps formulae, please refer link.

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 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”. On Select behaviour will run when we are clicking or selecting the dropdown list. As from above formulae we can see that on select of state dropdown first ClearCollect will run followed by the Collect.

Under 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.

Figure 3

Setting 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.

Figure 4

 

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

Figure 5

If there are any other ways to set the default values of dropdown, please let us know by replying. Thanks for visiting my blog. Please share and subscribe our site for more stuffs on PowerApps. In our next blog we will see how to create a PowerApps form for 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

Comments

  • Joanne
    February 21, 2019

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

    • Rakesh Pandey
      February 21, 2019

      Hi Joanne,
      Thanks for visiting our site. You can name the blank value to “Show All” by editiing the formula with below.
      ClearCollect(collection1,{Result:”Show All”}); Collect(collection1,Distinct(States,Title))

  • Joanne
    February 22, 2019

    Thanks Rakesh, it works!!

    • Rakesh Pandey
      February 22, 2019

      You are welcome !

Leave a Reply