cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ck25415
Post Patron
Post Patron

Create empty collection

Is it possible to create an empty collection?

1 ACCEPTED SOLUTION

Accepted Solutions
RezaDorrani
Dual Super User II
Dual Super User II

Hi @ck25415 

 

ClearCollect(colEmpty,Blank())

 

This will create a empty collection with a column called "Value"

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

6 REPLIES 6
hnguy71
Helper V
Helper V

You can create a collection with no data if that's what you need. For example:

ClearCollect(SampleCollection,
{
    Field1: Blank(),
    Field2: Blank()
});
RezaDorrani
Dual Super User II
Dual Super User II

Hi @ck25415 

 

ClearCollect(colEmpty,Blank())

 

This will create a empty collection with a column called "Value"

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

seadude
Memorable Member
Memorable Member

Hi @ck25415 ,
For an absolutely blank Collection, you can do ClearCollect(colTestBlank, {}). The results of this one are:

image.png

v-yutliu-msft
Community Support
Community Support

Hi @ck25415 ,

Could you describe more clearly about the empty collection's structure?

Does the collection have fields?

Which do you extrally want

1)have fields with empty value?

2)have no field?

3)something else?

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@RezaDorrani Thanks, that worked. I tried ClearCollect(emptyCol,"") and other suggestions from this post but the count  showed 1 even though there are no items in the collection.

NatEvansIT
Frequent Visitor

I wasn't sure what the official resolved resolution for this question was but I managed to work out how to create the default table layout I wanted and then to make sure it was empty. Posting here in case it helps others 🙂

 

//Create a Collection (table) that has column headers of SwitchID, SwitchModel, SwitchValue, SwitchPort, ConnectedDevicePort

ClearCollect(COL_SwitchHierachy,

{SwitchID: "",
SwitchModel: "",
SwitchValue: "",
SwitchPort: "",
ConnectedDevicePort: ""});

//The above creates a blank row, I want an empty table so I next clear the collection but keep the column headers

Clear(COL_SwitchHierachy)

 

 

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,235)