ClearData

How to Use the Power Fx ClearData  Function in Power Apps

What is the ClearData Function?

The ClearData function is a Power Fx function that removes all the data from a control or a collection. This can be useful if you want to clear out old data before entering new data, or if you want to reset a control or a collection back to its default state.

How to Use the ClearData Function in Power Apps

Using the ClearData function in Power Apps is relatively simple. Here’s how you can do it:

1. First, open the Power Apps Studio and open the app that you want to work on.

2. Select the control or collection that you want to clear.

3. In the formula bar, type the ClearData function followed by the control or collection that you want to clear. For example, if you want to clear a collection named “MyCollection”, you would type “ClearData(MyCollection)”.

4. Press the Enter key to execute the formula.

Examples of Using the ClearData Function

Here are a few examples of how you can use the ClearData function in Power Apps:

Example 1: Clearing a Text Input Control

Let’s say you have a text input control that you want to clear out before a user enters new data. To do this, you can use the ClearData function like this:


This will remove any data that's currently in the TextInput1 control.

Example 2: Clearing a Collection

Collections are a powerful feature in Power Apps that allow you to store data from multiple sources. If you want to clear a collection named "MyCollection", you can use the ClearData function like this:


This will remove all the data that’s currently in the MyCollection collection.

Example 3: Resetting a Form

If you have a form in your Power App that you want to reset back to its default state, you can use the ClearData function like this:


This will clear out all the data in the EditForm1 control and reset it back to its default state.

The ClearData function is a powerful tool that can help you manage the data in your Power Apps controls and collections. Whether you want to clear out old data before entering new data or reset a control or collection back to its default state, the ClearData function makes it easy to do so. So, the next time you're working with Power Apps, remember to keep the ClearData function in mind!

Power Apps Training Courses by G Com Solutions (0800 998 9248)