Show Message If Gallery is Empty in Power Apps

Are you facing any difficulties in showing a message if the gallery is empty in Power Apps? Follow this Power Apps tutorial to get all the information about how to show a message if a gallery is empty in Power Apps.

Here, we will discuss how to filter and display all SharePoint list records on a Gallery control using button controls and pop up a message when the Power Apps gallery is empty.

Show Message If Gallery is Empty in Power Apps

Let’s take a simple scenario: I have a SharePoint Online list named “Project Tracker” and this list contains the below fields.

  • Title: Default single line of text
  • Description: Multiple lines of text
  • Status: Choice
  • Start Date: Date and time
  • End Date: Date and time
Show message if a gallery is empty in power apps

Now, I want to display these SharePoint list records on a gallery control based on the Choice field [Status] like below.

how to show message if gallery is empty in power apps

Also, I would like to show a message if the Power Apps gallery is empty, like “No Results Found” as in the Screenshot below.

how to show message if a gallery is empty in power apps

To work around this, follow the below-mentioned steps. Such as:

1. Open Power Apps with your respective Microsoft credentials -> Create a Blank canvas app and connect it to the respective SharePoint list like below.

Show Message If Power Apps Gallery is Empty

2. On the Power Apps Screen -> Insert a Gallery control and set Its Items property as:

Items = 'Project Tracker'
Show Message If Power Apps Gallery control is Empty

3. Then, insert three Button controls to filter the gallery control and set their OnSelect property to the code below.

OnSelect = Set(
    gblFilterProjects,
    Self.Text
)

Where,

  • gblFilterProjects = Power Apps Global Variable Name
Show Message If Gallery Control is Empty in Power Apps

4. Now, filter the Power Apps gallery control using the button control selected value. For that, select the Gallery control and update the Items property code as:

Items = Filter(
    'Project Tracker',
    'Status'.Value = gblFilterProjects
)
  • ‘Project Tracker’ = SharePoint Online list
  • ‘Status’ = SharePoint list choice field
  • gblFilterProjects = Power Apps global variable
Show message if a gallery control is empty in power apps

5. Also, set the Visible property of a Gallery control as shown below.

Visible = !IsEmpty('Project Tracker') And !IsEmpty(
    Filter(
        'Project Tracker',
        Status.Value = gblFilterProjects
    )
)

Where,

  • !IsEmpty() = This function helps us to test whether a table contains any record and it is equivalent to using the CountRows() function and checking for zero
  • ‘Project Tracker’ = SharePoint list
Show Message If a Power Apps Gallery is Empty

6. Once it is done, click on the Preview button and click on the button controls to filter and display the SharePoint list records as in the screenshot below.

Pop Up a message when Power Apps Gallery is empty

7. You can see below that there is an empty gallery control [When the user selects the In Progress button, it will give a blank gallery control]

Pop up a message when Power Apps Gallery control is empty

8. Now, we need to show or pop up a message, i.e., [No Results Found], when the gallery is empty. To do so, insert a Text label and set its Text and Visible property as shown below

Text = "No Results Found"

Visible = CountRows(gal_Projects.AllItems)=0

Where,

  • “No Results Found” = Label Text
  • gal_Projects = Power Apps gallery name
  • CountRows() = This function is used to count the number of records in a table
how to pop up a message when power apps gallery is empty

9. Same way insert a Search icon and set its Visible property to the code below.

Visible = CountRows(gal_Projects.AllItems)=0
how to pop up a message when power apps gallery control is empty

10. Once your app is ready, Save, Publish, and Preview the app. Whenever a user selects an empty record gallery, it will show a message on the text label, as in the screenshot below.

how to show a message when power apps gallery is empty

This is all about how to show a message if a gallery is empty in Power Apps.

See also  Power Apps Disable Button

Conclusion

I hope this Power Apps tutorial explains how to show message if a gallery is empty in Power Apps. Like:

  • How to retrieve the SharePoint list records on a Gallery control
  • Filter and display SharePoint list records using button controls
  • How to pop up a message when the Power Apps gallery is empty

You may like the following tutorials:

>