How to Make Power Apps Data Table Empty?

PowerApps Data table control presents data in a structured table format. The data table contains a Header for each field to display the data. In this Power Apps tutorial, I have explained how to make a Power Apps data table empty with simple examples.

I will also show you how to display a message if the Power Apps data table is empty.

Power Apps Data Table Empty

While working with the Power Apps data table control, sometimes we need to make a data table empty. Now, I will show you how to make the Power Apps data table empty with simple examples.

How to Make Power Apps Data Table Empty using Button Control

I have created a Power Apps collection [colEmployeeRegistration] with some records. And I want to display those records on the Data table control.

Input:

Power Apps Empty Data Table

Now, I would like to make the Power App data table empty or reset the data table by clicking the button control. Have a look at the below screenshot for the output:

Output:

Power Apps Data Table Blank

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

1. Open your Power Apps app -> Select the App object [From the left navigation] and set its OnStart property to the code below.

Code:

Items = ClearCollect(
    colEmployeeRegistration,
    {
        Name: "Smith John",
        Email: "smithjohn56@gmail.com",
        Designation: "Analyst"
    },
    {
        Name: "Jones Robort",
        Email: "jonesrobort12@gmail.com",
        Designation: "Team Lead"
    },
    {
        Name: "Reema Sean",
        Email: "reemasean142@gmail.com",
        Designation: "Manager"
    },
    {
        Name: "David Jones",
        Email: "davidjones89@gmail.com",
        Designation: "Analyst"
    }
)

Where,

  • colEmployeeRegistration = Power Apps Collection Name
  • Name, Email, Designation = Collection Headers/Columns
  • “Smith John”, “smithjohn56@gmail.com”, etc… = Collection Records/Rows
Power Apps Data Table Empty

2. Next, Insert a Data table control and set its Items property as:

Items = colEmployeeRegistration
Power Apps Data Table Control Empty

3. Now, insert a Button control and set its OnSelect property to the code below.

OnSelect = Clear(colEmployeeRegistration)                                                 OR

                    = ClearCollect(colEmployeeRegistration,Blank())                 OR

                    = ClearCollect(colEmployeeRegistration,"")                             OR

Where,

  • Clear() = The Power Apps Clear() function is used to remove or delete all the records of a collection
  • colEmployeeRegistration = Name of the collection
  • Blank() = This function returns a blank value or stores a Null value in the data source
Data Table Control Empty in Power Apps

4. Once your app is ready, Save, Publish, and Preview the app. Whenever the user clicks on the button control, the data table will display empty records like the one below.

Power Apps Data Table Control Blank

How to Make Power Apps Data Table Empty using Variables

In this section, I will discuss how to make the Power Apps data table empty using two different variables. Such as:

1. Make Power Apps Data Table Empty using Context Variable

I will also take the above Power Apps data table records [Employee Details] for this example. Now, I would like to make a data table empty using local or context variable [Whenever the user clicks the button control, the data table will be empty, and at the same time, when the user clicks the button control again, the data table will display all the records]

Output:

How to Make Power Apps Data Table Empty using Variables

To do so, follow the below steps.

1. On the Power Apps Screen -> Select the Button control and set its OnSelect property as:

OnSelect = UpdateContext({ showTable: !showTable })

Where,

  • UpdateContext() = We can use this function to create the context or local variable
  • showTable = Context variable name

2. Next, select the Data table and set its Items property to the code below.

Items = If(showTable, colEmployeeRegistration)

Where,

  • If() = This If() function is used to evaluate the unrelated conditions
  • colEmployeeRegistration = Power Apps collection name
Make Power Apps Data Table Empty using Variables

3. When a user clicks on the button control [First time], the data table will be empty. At the same time when you click again the button control, the data table will display all the collection records.

How to Make Data Table Empty using Variables in Power Apps

2. Make Power Apps Data Table Empty using Global Variable

Similarly, we will see how to make a Power Apps data table empty using a global variable. Here, also I will take the above Data table records [Employee Details] for this example. Have a look at the below screenshot for output.

Output:

Make Data Table Empty using Variables in Power Apps

To work around this, follow the below steps.

1. Select the Power Apps screen -> Set its OnVisible property to the code below.

OnVisible = Set(ShowData, true)

Where,

  • Set() = This Power Apps Set() function is used to create the global variable
  • ShowDate = Global variable name
Make a Data Table Empty using Variables in Power Apps

2. Next, select the Button control and set its OnSelect property as:

OnSelect = Set(ShowData, !ShowData)
Make the Data Table Empty using Variables in Power Apps

3. Now, select the Data table and set its Items property to the code below.

Items = Filter(
    colEmployeeRegistration,
    Or(
        ShowData,
        Name = " "
    )
)

Where,

  • Filter() = This function is used to filter the records based on one or more criteria
  • colEmployeeRegistration = Power Apps collection name
  • Name = Power Apps collection field
How to Make a Data Table Empty using Variables in Power Apps

4. Once your app is ready, Save, Publish, and Preview the app. Whenever the user clicks on the button control [First time], the data table will be empty. At the same time, when you click the button control again, the data table will display all the collection records.

This way, we can make a Power Apps data table empty using variables.

How to Make the Data Table Empty using Variables in Power Apps

Make Power Apps Data Table Empty using Dropdown Control

I have a SharePoint Online list named “Project Tracker” and this list contains the below fields.

Input:

Column NameData Type
TitleIt is a default single line of text
DescriptionMultiple lines of text
StatusChoice
Start DateDate and Time
End DateDate and Time
How to make Power Apps data table empty

In Power Apps, there is a Data table control and a Dropdown control. Now, I would like to make the data table empty when the dropdown control is empty. That means if no item is selected in the dropdown or if the dropdown is blank, then the data table will also be blank or empty. The data table does not retrieve any records from the SharePoint List.

Output:

How to make data table control empty in Power Apps

To achieve it, follow the below steps.

1. Connect the specific SharePoint list to the Power Apps Canvas app like below.

How to make a Power Apps data table empty

2. On the Power Apps screen, set its OnVisible property to the code below.

OnVisible = ClearCollect(
    colProjects,
    {Status: ""}
);
Collect(
    colProjects,
    Distinct(
        'Project Tracker',
        Status.Value
    )
)

Where,

  • colProjects = Power Apps Collection Name
  • Status = SharePoint List Choice Field Column
  • Distinct() = This function can be used to remove the duplicates in the data source
  • ‘Project Tracker’ = SharePoint Online List
How to make a Power Apps data table control empty

3. Next, insert a Dropdown control and set its Items property as:

Items = colProjects
How to make Power Apps data table control empty

4. Now, insert a Data table control and set its Item property to the code below.

Items = If(
    Drp_Status.Selected.Value ="",'Project Tracker',
    Filter(
        'Project Tracker',
        Status.Value = Drp_Status.Selected.Value
    )
)

Where,

  • If() = The If() function tests one or more conditions until a true result is found
  • Drp_Status = Power Apps Dropdown Name
  • Filter() = We can use Filter to find a set of records that match one or more criteria 
How to make the Power Apps data table control empty

5. Save, Publish, Reload, and Preview the app. When the user selects a blank value in the dropdown or if the dropdown is blank, the data table displays empty records. Have a look at the below screenshot for output.

How to make the Power Apps data table empty

Show Message If Power Apps Data Table is Empty

In the last, I will explain how to show the message if a Power Apps data table is empty. I will also take the above SharePoint list [Project Tracker] for this example.

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

Input:

How to make a data table empty in Power Apps

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

Output:

How to make a data table control empty in Power Apps

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

1. On the Power Apps Screen -> Insert a Data table control and set its Items property as:

Items = 'Project Tracker'
Show message if a Power Apps data table is empty

2. Then, insert three Button controls to filter the data table control set their OnSelect property to the code below.

OnSelect = Set(
    gblFilterProjects,
    Self.Text
)

Where,

  • gblFilterProjects = Power Apps Global Variable Name
Show message if Power Apps data table is empty

3. Now, filter the Power Apps data table control using the button control selected value. For that, select the data table and update the Items property code as:

 Filter(
    'Project Tracker',
    'Status'.Value = gblFilterProjects
)

Where,

  • ‘Project Tracker’ = SharePoint Online list
  • ‘Status’ = SharePoint list choice field
  • gblFilterProjects = Power Apps global variable
Show message if Power Apps data table control is empty

4. Also, set the Visible property of a Data table control.

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
How to make data table blank in Power Apps

5. Once it is done, click on the Preview button and click on the button controls to filter and display the SharePoint list records on the data table control.

Refer to the below screenshot:

How to make the data table blank in Power Apps

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

How to make a data table blank in Power Apps

7. Now, we need to show or pop up a message, i.e., [No Results Found], when the data table is empty. To do so, insert a Text label, and Search icon. Next, set their Text and Visible properties as shown below

Text = "No Results Found"

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

Where,

Show message if Power Apps data table is blank

8. Once your app is ready, SavePublish, and Preview the app. Whenever a user selects an empty record data table, it will show a message on the text label, as in the screenshot below.

Show message if a Power Apps data table is blank

This way, we can show the message if a data table is empty in Power Apps.

Conclusion

I have explained, with examples, how to make the Power Apps data table empty using different ways. Now, I hope if you get any similar requirements to make the Power Apps data table empty, you can do it using the above examples. Also, I have explained how to Show a Message If the Power Apps Data Table is Empty.

You may also like:

>