cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

How to delete blank collection columns

Hello PowerApps,

 

How do I make a collection that only has values? I would want this change dynamically. This could be down with some code at were the collection is being initialize or some other way.

 

Thanks,

AskingQuestions

5 REPLIES 5
Highlighted
Super User III
Super User III

@Anonymous 

Can you explain a little further what you are trying to do?

You cannot remove a column from a collection if it has somewhere been defined either directly in a formula, or as a connection/collect to a datasource.

You can however derive another collection or table from the original collection and drop the column in the process to your new collection/table.

 

In other words...

ClearCollect(colA, {col1:"val1", col2:"val2", col3:"val3"})

would result in a collection called colA that has one record with three columns in it.  The fact that you defined this will not allow you to remove, say, col2 unless you manually altered the above formula to remove it.

But, you could derive another collection from it such as:

ClearCollect(colB, DropColumns(colA, "col2"))

this would result in a collection called colB that has one record in it and two columns - col1 and col3.

 

I hope that helps some.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted
Anonymous
Not applicable

Hi @RandyHayes ,

 

That works with me (having anthor collections).

 

I wanted to have collection to have columns that had something.

 

How would dynmically change create a new collcetion with only columns that had data?

 

This the could to test if there is a blank column or not: CountRows(
Filter(DataViewer, !(IsBlank('Column') || 'Column' = "0")); (Thanks Again)

 

Thanks,

AskingQuestions

 

 

Highlighted

@Anonymous 

Are you truly trying to create another collection minus the blank columns, or are you trying to display anything but blank columns?  Unless you have a very specific purpose for the seperate collection and no other final formula option is available, then I would consider just hiding or displaying columns as needed.

I have a sense that you are trying to work with a datatable control based on this question and some of the other questions you've just posted.

If that is the case, then you might want to consider instead putting the formula to count the rows in the Visible property of the table column.

This formula in the Visible property of your data column would hide or show the column based on any data being in them.

CountRows(
       Filter(DataViewer, !(IsBlank('Column') || 'Column' = "0")
     )>0

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Highlighted
Anonymous
Not applicable

hi@RandyHayes ,

I am truly trying to make a collection minus the blank columns. 

 

And yes I am going to export the collection with no blank columns into a new excel file (but this excel should be based on a template, it should be an excel file of the collection). That is my final goal, but that might be anthor post.

 

Thanks,

AskingQuestions

Highlighted

Hi @Anonymous ,

Do you want to save data to collection except the columns that have blank value?

Since saving data to collection need to clearly write the column name, so I think the function that you want can not work dynamically. Using variable to replace fieldname in clearcolloection function will not work.

 

As an alternative way, I suggest you firstly justify which columns having blank value and then save other data expect those columns.

1)add labels below every columns

2)set labels' Text:

If(CountRows(tablename)=CountIf(tablename,!IsBlank(fieldname)),true,false)

Please replace fieldname with every fields'name. One lable represents one field.

3)If the label display false, then that field has blank value.

When you save data to collection, do not save those fields.

 

 

 

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.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (7,427)