How to Create Empty Collection in Power Apps?

Some Power Apps newbies may have a question: “Can I create an empty collection in Power Apps?

So the answer is YES, a blank Power Apps Collection can be created. A Power Apps collection can also be created with no or empty data.

Check out this Power Apps tutorial to learn what Power Apps Empty Collection means and how to create empty collection in Power Apps.

Also, we will cover some more topics below:

  • Power Apps Create Empty Collection With Columns/Headers
  • Power Apps Create Empty Collection With SharePoint Columns
  • Power Apps Collection Blank Replace Value

Check out Power Apps Gallery Control Examples Download [20 Various Real Scenarios]

How to Create Empty Collection in Power Apps

  • Power Apps Empty collections show that the collection is empty and has no values. Since all empty collections are immutable, they can be freely shared once created. These empty collections are individuals; thus, this method cannot generate a new object.
  • Power Apps Blank Collection will always generate a column called “Value“. Let’s create it by taking a simple scenario.

Example:

  • There will be a Power Apps Button control and a Gallery control. The blank collection will be created with no values whenever users tap the button [Create Blank Collection].
  • The gallery is displaying blank because no values exist in the created collection.
Power Apps Collection Blank
  • To achieve this, we can use any of the below codes on the Button’s OnSelect property: [Not only the button’s OnSelect but also you can use the code below either on the App’s OnStart property or Screen’s OnVisible property as per your need].
OnSelect = ClearCollect(
    colBlankData,
    Blank()
)

OR

OnSelect = ClearCollect(
    colBlank,
    {}
)

OR

OnSelect = ClearCollect(colEmpty,"")

Where,

See also  Power Apps Employee Engagement Survey Example

colBlankData, colBlank, colEmpty = Collection names

Create empty collection power apps
  • Then, insert a Vertical Gallery Control and set its Items property as:
Items = colBlankData
PowerApps Collection Blank
  • Select the Label from the gallery and set its Text property to the code below:
Text = ThisItem.Value

As I discussed above, the blank collection will create a column called Value.

Power Apps Create a Blank Collection
  • Save, Publish, and Preview the app. Click on the Button [Create Blank Collection] -> Go to Variables (x) -> Select ellipses () of the created blank collection -> Click on the View Table. You will view the empty collection as shown below.
Create a Blank Collection in Power Apps

This is how we can create Power Apps Collection Blank values.

Power Apps Create Empty Collection With Columns

Next, we will see how to work with Power Apps Create Empty Collection With Columns.

  • When a user hits the button [Create Blank Collection], the collection will be created with the provided columns and headers. However, it will contain blank records.
  • To work around this, apply the formula below on the Button’s OnSelect property:
OnSelect = ClearCollect(
    colEmptyData,
    {
        EventName: Blank(),
        EventLocation: Blank(),
        EventDate: Blank()
    }
);

Where,

  1. colEmptyData = Collection name
  2. EventName, EventLocation, EventDate = Column or Header Names of the collection

Refer to the image below.

Power Apps Create Empty Collection With Columns
  • Save, Publish, and Preview the app. Click on the Button [Create Blank Collection] -> Go to Variables (x) -> Select ellipses () of the created collection -> Click on the View Table. You will view the empty collection with specified headers, as shown below.
Power Apps create blank collection with columns

This is how to create an empty collection with columns in Power Apps.

Power Apps Create Empty Collection With SharePoint Columns

Similarly, suppose you want to create an empty collection with the SharePoint Columns. Then, refer to the example below.

  • I have a SharePoint List named Scheduled Events with various columns like:
See also  Power Apps Modern Spinner Control - How to Use
ColumnDatatype
TitleSingle line of text
LocationChoice
DepartmentChoice
Event ManagerPerson
Start DateDate and time
End DateDate and time
Created ByPerson

Also, the below list has some records.

Power Apps Create Empty Collection With SharePoint Columns
  • I want to create an empty collection with all these SharePoint Columns in Power Apps.
  • To do so, Select the Button [Create Blank Collection] and set its OnSelect property as:
OnSelect = Collect(
    colScheduledEvents,
    Defaults('Scheduled Events')
)

Where,

  1. colScheduledEvents = Collection Name
  2. Scheduled Events = SharePoint List Name

Also, you can use the ClearCollect function.

Power Apps Create Empty Collection With SharePoint Fields
  • Save, Publish, and Preview the app. Click on the Button [Create Blank Collection] -> Go to Variables (x) -> Select ellipses () of the created collection -> Click on the View Table. You will view the empty collection with all SharePoint Columns, as shown below.
PowerApps Create Empty Collection With SharePoint Columns

This is how to work with Power Apps Create Empty Collection With SharePoint Columns.

Power Apps Collection Blank Replace Value

Here, we will discuss Power Apps Collection Blank Replace Value.

  • For example, the screenshot below represents two Power Apps Gallery Controls and two Button Controls [Create Collection & Power Apps Collection Blank Replace Value].
  • When a user clicks on the first button [Create Collection], the collection will be created from the specific SharePoint list [IT Help Desk]. Also, in the first gallery, you can see that some of the Progress column values are blank because they are empty in the SharePoint List.
  • I want to replace all empty progress values with “0” using the Power Apps Collection, as shown in the second gallery.
Power Apps Collection Blank Replace Value

To achieve this, follow the steps below:

  • Add a Button [Create Collection] and set its OnSelect property as:
OnSelect = ClearCollect(
    colHelpDeskDetails,
    'IT Help Desk'
)

Where,

  1. colHelpDeskDetails = Collection Name
  2. IT Help Desk‘ = SharePoint List Name
powerapps collection blank replace value
  • Then, insert another Button control [Power Apps Collection Blank Replace Value] and apply the code below on its OnSelect property:
OnSelect = ClearCollect(
    colBlankReplaceValue,
    colHelpDeskDetails
);
UpdateIf(
    colBlankReplaceValue,
    Progress = Blank(),
    {Progress: 0}
);

Where,

  1. colBlankReplaceValue = New Collection Name
  2. colHelpDeskDetails = Collection name that you have created before
  3. Progress = SharePoint Number Column
  4. 0 = Specify the value that you want to update or replace
See also  Power Apps Modern Spinner Control - How to Use

The above code specifies wherever the Progress value is blank in the collection, update with the 0 value.

replace value in power apps collection blank
  • To display the result in the gallery control, set its Items property as:
Items = colBlankReplaceValue

Refer to the image below.

Replace Cells In A PowerApps Collection With Blank Values
  • Save, Publish, and Preview the app. Click on the Button [Power Apps Collection Blank Replace Value]. The gallery blank progress value will now update with a 0 value, as in the figure below.
Replace Cells In A Power Apps Collection With Blank Values

This is how to work with Power Apps Collection Blank Replace Value.

Additionally, you may like some more Power Apps tutorials:

In this Power Apps tutorial, we learned what Power Apps Empty Collection means and how to create empty collection in Power Apps.

Also, we discussed some more related topics like:

  • How to Create Power Apps Empty Collection With Columns/Headers
  • How to Create Power Apps Empty Collection With SharePoint Columns
  • Working with Power Apps Collection Blank Replace Value
>