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.
- 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,
colBlankData, colBlank, colEmpty = Collection names
- Then, insert a Vertical Gallery Control and set its Items property as:
Items = colBlankData
- 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.
- 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.
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,
- colEmptyData = Collection name
- EventName, EventLocation, EventDate = Column or Header Names of the collection
Refer to the image below.
- 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.
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:
Column | Datatype |
---|---|
Title | Single line of text |
Location | Choice |
Department | Choice |
Event Manager | Person |
Start Date | Date and time |
End Date | Date and time |
Created By | Person |
Also, the below list has some records.
- 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,
- colScheduledEvents = Collection Name
- Scheduled Events = SharePoint List Name
Also, you can use the ClearCollect function.
- 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.
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.
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,
- colHelpDeskDetails = Collection Name
- ‘IT Help Desk‘ = SharePoint List Name
- 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,
- colBlankReplaceValue = New Collection Name
- colHelpDeskDetails = Collection name that you have created before
- Progress = SharePoint Number Column
- 0 = Specify the value that you want to update or replace
The above code specifies wherever the Progress value is blank in the collection, update with the 0 value.
- To display the result in the gallery control, set its Items property as:
Items = colBlankReplaceValue
Refer to the image below.
- 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.
This is how to work with Power Apps Collection Blank Replace Value.
Additionally, you may like some more Power Apps tutorials:
- Power Apps Collection Distinct Filter [With Different Data Types]
- How to Add Image in a Power Apps Collection
- How to Add Gallery Data to a Collection in Power Apps
- How to get Collection Column Names in Power Apps [From 3 Different Datasources]
- Power Apps Sequence Function [With Various Examples]
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
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