I was working with a requirement to add a blank or empty value to a Power Apps Dropdown control. For this, I researched it and got various methods to achieve this. Yes, this technique is quite interesting and easy to learn.
This article will assist you in knowing how to add a blank value to a Dropdown list in Power Apps with different scenarios and approaches.
Additionally, we will discuss inserting a blank value to the Power Apps Dropdown with the SharePoint List distinct value.
How to Add a Blank Value to a Dropdown List in Power Apps
Here, We will see how to add an empty value in the Power Apps Dropdown control with different scenarios.
- The screenshot below represents a Power Apps Dropdown control. The dropdown values are retrieved from a Sharepoint List (Product Info).
- The Dropdown control always displays the first choice value from the SharePoint list. Nevertheless, I prefer to have a blank or empty value in the dropdown control each time I open the application.
- For example, the dropdown control typically displays the value as Bread. I want to set a blank value (the default value) in place of the Bread value so that when I open the application, the dropdown control will display a blank choice, as seen below.
- Below is the SharePoint List (Product Info). This list contains three columns:
Column | Data type |
---|---|
ID | Number |
Title | Single line of text |
Product Location | Single line of text |
Refer to the image below:
- To set a blank value to the dropdown control, you must create a PowerApps Collection on Screen’s OnVisible property and then bind this created collection to the Dropdown control.
- First, on the Power Apps screen, go to the screen’s OnVisible property and apply the code below:
OnVisible = ClearCollect(
ProductsWithBlank,
{Product: Char(160)}
);
Collect(
ProductsWithBlank,
'Product Info'.Title
)
Where,
- ProductsWithBlank = Provide a Collection name
- Product = Specify a header name of the collection.
- ‘Product Info’ = SharePoint list name
- Title = Specify the column that you want to display in the dropdown control
- To avoid the dropdown bug where blank entries appear with a smaller height (which can be hard to select on small screens, such as phones). So, to avoid this, you can work around this [Char(160)] by defining the name as a ‘non-breaking space.’
- Next, Select the dropdown control and set its Items property to the collection as:
Items = ProductsWithBlank
- Now save and publish the app. Once you reopen the app again, then you will see a blank value appear in the dropdown control.
This way, we can add a blank value to the Power Apps Dropdown control.
Add Blank Value to Power Apps Dropdown with SharePoint List Distinct
In this scenario, we will discuss adding a blank value to the Power Apps Dropdown with the SharePoint List distinct value.
Example – 1:
In Power Apps, there is a Button control [Create Collection & Add Blank to Dropdown] and a Dropdown control. Upon clicking the button, the user will create a collection with a blank value and add it to the dropdown menu, as demonstrated below.
To achieve this, follow the steps below:
- Below is a SharePoint list named Products. This list has two columns:
- ID = Number
- Title = Single line of text
- In Power Apps, insert a Button and set its Text property as:
Text = Create Collection & Add Blank to Dropdown
- Select the button and apply the code below on its OnSelect property:
OnSelect = ClearCollect(
colBlank,
{item: Blank()}
);
ClearCollect(
colBlankValue,
colBlank,
Distinct(
Products,
Title
)
)
Where,
- colBlank, colBlankValue = Collection names
- Products = SharePoint list name
- Title = SharePoint column name
In this case, a collection with a blank value is created, and the blank value is then added to another collection with a distinct SharePoint value.
NOTE:
We can use the OnStart or OnVisible properties of the App or the Screen to create the collection in addition to the Power Apps Button’s OnSelect property.
- Next, add a Dropdown control and set its Items property to the specific collection as:
Items = colBlankValue
As seen below, ensure the Dropdown Value property is also set to Value.
- At last, Save, Publish, and Preview the app. Click on the button and then expand the dropdown menu. The blank value has been added to the Power Apps dropdown control.
Example – 2:
A Power Apps Dropdown control displaying every vendor name from the SharePoint list can be seen in the image below. The dropdown menu didn’t have an empty value before, but it will look like the second image after adding one.
To workaround with this, follow the instructions below:
- There is a SharePoint list called Products having these many columns below:
Column | Data type |
---|---|
ID | Number |
Title | Single line of text |
Vendor | Choice [APPLE, SAMSUNG, DELL, HP, LENOVO] |
Customer Name | Single line of text |
- Next, in Power Apps, add a Dropdown control and set its Items property as:
Items = Distinct(Products,Vendor.Value)
Where,
- Products = SharePoint List Name
- Vendor = SharePoint Choice Column
You cannot see a blank value once you preview the app and expand the dropdown menu. It will only show you the choices except the empty value.
- To add a blank value to the Power Apps dropdown control, apply the formula below on its Items property:
Items = Ungroup(
Table(
{Items: Table({Result: Blank()})},
{
Items: ForAll(
Distinct(
Products,
Vendor.Value
),
{Result: ThisRecord.Value}
).Result
}
),
"Items"
)
- Also, ensure the Dropdown Value property is set to Result, as shown below.
- Finally, Save, Publish, and Preview the app. Expand the dropdown menu, and you can see a new blank value has been added, as shown in the figure.
This way, we can add blank values to the Power Apps Dropdown with a SharePoint list of distinct items.
Conclusion
The placeholder “blank” stands for “no value” or “unknown value.” If the user has not selected anything, the Selected property of the Power Apps Dropdown control is blank.
Now, from this tutorial, I hope you have some ideas and are confident about adding a blank value to a Power Apps Dropdown menu with various techniques.
Moreover, you may like some more Power Apps tutorials:
- Sort Dropdown Choices Alphabetically in Power Apps
- PowerApps Dropdown Gallery
- PowerApps Cascading Dropdown
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com