Power Apps is a powerful platform developed by Microsoft that allows users to create custom business applications using different types of control like Text inputs, Dropdown, Forms, Gallery controls, etc.
While working with the dropdown control, we sometimes need to validate if a dropdown is empty or not in Power Apps; if it is empty, we perform some actions (like displaying any notifications, disabling buttons, etc.) according to it.
We can use the IsEmpty() or IsBlank() function in the Power Apps Dropdown Control for such cases.
In this Power Apps article, I will show you how to check if Power Apps Dropdown is empty using simple examples.
How to Check If Power Apps Dropdown is Empty
Let me show you how to check the empty Power Apps dropdown with two scenarios.
Scenario-1:
In Power Apps, there is a Dropdown control and a Text label control. If the dropdown has some records, the text label displays the text like “Dropdown has a value.”
Similarly, if the dropdown has no value or is empty, the text label displays the text like “Dropdown is empty.”
Have a look at the below screenshot for the output:
To achieve it, follow the below-mentioned steps. Such as:
1. In the Power Apps Screen, Insert a Dropdown control and set its Items property to the code below.
Items = ["Not Started", "In Progress", "Completed"]
2. Then, insert a Text label control and set its Text property as:
Text = If(
IsBlank(drp_Items.Selected),
"Dropdown is empty",
"Dropdown has a value"
)
Where,
- drp_Items = Power Apps dropdown name
3. Once your app is ready, Save, Publish, and Preview the app. The text label displays the text like “Dropdown has a value” because the dropdown has some values.
4. However, if the Dropdown control has no values or the dropdown is empty, then the text label displays the text like “Dropdown is empty” like below.
This way, you can check if the dropdown is empty in Power Apps.
Scenario-2:
I have a Power Apps New Form with the SharePoint list records [Expense Tracker], and inside this is a dropdown control containing the choice field items [Expense Type].
Also, a button control [Submit] is under the Power Apps form, as shown below.
Whenever the user enters a new record in the Power Apps form, the dropdown control selects the first value as a default value. But, this is not the right way to select the value in the dropdown.
For that, I have added a blank value to the dropdown control in the first place, like below.
Additionally, if the user does not select any value from the dropdown, the label text will display a message like “Please Select the Expense Type,” and the button control will be disabled.
When the user selects any value from the dropdown control, the text message disappears, and the button control is enabled. Refer to the below screenshot:
To work around this example, follow the below steps.
1. On the Power Apps Screen -> Insert an Edit form control and set its DataSource property as:
DataSource = 'Expense Tracker'
Where,
- ‘Expense Tracker’ = SharePoint Online List
Note: Whenever you want to submit the new record from Power Apps form to the SharePoint list, make sure you need to set its DefaultMode property as "FormMode.New"
2. To add a blank value to the dropdown control, select the dropdown and set its Items property using the below code.
Items = Ungroup(
Table(
{myDropdownOptions: Table({ExpenseType: Blank()})},
{myDropdownOptions: Choices([@'Expense Tracker'].ExpenseType)}
),
"myDropdownOptions"
)
Where,
- Blank() = This Blank is a placeholder for “no value” or “unknown value”
- ExpenseType = SharePoint list choice field
3. Then insert a Text label under the dropdown control and set its Text and Visible property to the code below.
Text = "Please Select the Expense Type"
Visible = IsBlank(drp_ExpenseType.Selected.Value)
Where,
- drp_ExpenseType = Power Apps dropdown name
4. Next, insert a Button control [Submit] and set its OnSelect property as:
OnSelect = SubmitForm(frm_Records);
ResetForm(frm_Records)
Where,
- frm_Records = Power Apps form control name
5. Now, you must set the Button control’s DisplayMode property. For that, follow the below code,
DisplayMode = If(
drp_ExpenseType.Selected.Value =Blank(),
DisplayMode.Disabled,
DisplayMode.Edit
)
6. Finally, Save, Publish, and Preview the app. If the dropdown is empty or the user does not select any value from the dropdown, then he/she will get the error message, and the button control is not enabled.
7. Whenever the user selects any value from the dropdown, the message will disappear, and the button will be enabled. Once you submit the new record, it will be added to the SharePoint list below.
This is how we can work with the Power Apps: check if the dropdown is empty.
Also, you may like some more Power Apps articles:
- Add All Option in Power Apps Dropdown
- Display SharePoint Person or Group Column in Power Apps Dropdown
- Filter Power Apps Gallery By Multiple Dropdowns
I trust this Power Apps tutorial taught in detail information about the Power Apps check if the dropdown is empty with simple and real-time scenarios.
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