How to Remove a Column From Power Apps Collection? [Remove Multiple Columns From Power Apps Collection]

This Power Apps tutorial will teach us how to remove a column from Power Apps collection.

Additionally, we will discuss the DropColumns() function to remove a column from the Power Apps collection using a single line of code. And also we will see how to remove multiple columns from a Power Apps collection.

Remove a Column From Power Apps Collection

  • Creating a Power Apps collection makes adding a group of similar items to a table easier. Also, you can easily remove unwanted columns or rows.
  • The screenshot below shows a Power Apps collection named “colProducts” [1st image]. In this collection, I have added data with different columns. Such as:
ProductID
ProductName
EstimatedPrice
ExactPrice
  • I need to create another collection [colProductRemove] using the previous collection. In this collection, I do not want to display a column named “EstimatedPrice“. Apart from this column, all the below columns will appear in this collection, and the result will be displayed in a Data table control [2nd image].
ProductID
ProductName
ExactPrice

Refer to the screenshot below.

Remove Column in Power Apps Collection

We can use the Power Apps DropColumns() function to remove specific columns in a Power Apps collection.

To achieve it, follow the below steps. Such as:

  • Open Power Apps with your valid Microsoft 365 credentials -> Create a Power Apps Canvas app where you want to create a Power Apps collection -> Select a screen and rename it to ProductDetailsScreen.
  • Insert a Power Apps Button control -> Set its OnSelect property code like below.
OnSelect = ClearCollect(colProducts,{ProductID:"SP001", ProductName:"Laptop", EstimatedPrice:1850, ExactPrice:1700}, {ProductID:"SP002", ProductName:"Mobile", EstimatedPrice:700, ExactPrice:800}, {ProductID:"SP003", ProductName:"Printer", EstimatedPrice:870, ExactPrice:1000}, {ProductID:"SP004", ProductName:"Tablet", EstimatedPrice:900, ExactPrice:1100}, {ProductID:"SP004", ProductName:"Calculator", EstimatedPrice:1000, ExactPrice:700})

Where,

  1. colProducts = Collection name
  2. ProductID, ProductName, EstimatedPrice, ExactPrice = Collection Columns/Headers
  3. “SP001”, “Laptop”, 1850, 1700 = Collection Rows/Records
How to Remove a Column from the Power Apps Collection
  • Then, insert a Power Apps Data table control and set its Items property as:
Items = colProducts
  • To display the collection fields in the data table control, click the Edit fields option and add fields as needed.
Remove a Column from the Power Apps Collection
  • Now, click on the button to display the Power Apps collection with all the columns as shown below.
How to Remove a Column From Power Apps Collection
  • We need to remove the unwanted column, i.e., “EstimatedPrice,” using the DropColumns() function. To do so, insert a button control (Remove unwanted column) on the same screen and set its OnSelect property code as:
OnSelect = ClearCollect(colProductRemove,DropColumns(colProducts,"EstimatedPrice"))

Where,

  1. colProductRemove = It is the collection name
  2. DropColumns = We can use this function to exclude columns from our Power Apps collection
  3. colProducts = It is the source collection
  4. “EstimatedPrice” = It is an unwanted column that we want to remove from a Power Apps collection.
Remove Column from a Power Apps Collection
  • Next, insert another Data table and set its Items property as:
Items = colProductRemove
  • To display the collection fields in the data table control, click the Edit fields option and add fields as needed.
Remove Column from the Power Apps Collection
  • Now, click the button control to display the Power Apps collection without an unwanted column, as shown below.
How to Remove Column from the Power Apps Collection

This is how to remove a column from Power Apps Collection and displaying the remaining columns in a Data table control.

How to Remove Multiple Columns from Power Apps Collection

Similarly, we will see how to remove multiple columns from the Power Apps collection. Here, I will take the same above example.

  • In this example, I want to remove two columns from the collection, i.e., Product ID and EstimatedPrice. After removing these columns, the data table control [2nd image] will look like the image below:
Remove Multiple Columns from the Power Apps Collection

To do so, follow the below-mentioned steps. Such as:

  • On the Power Apps screen -> Insert a button control (Remove more columns) and set its OnSelect property code like below.
OnSelect = ClearCollect(colRemoveColumns,DropColumns(colProducts,"ProductID","EstimatedPrice"))

Where,

  1. colRemoveColumns = Collection name
  2. colProducts = It is a source collection
  3. “ProductID”, and “EstimatedPrice” = These are unwanted columns we want to remove from a Power Apps collection.
How to Remove Multiple Columns from Power Apps Collection
  • Then, insert another Data table and set its Items property as:
Items = colRemoveColumns
  • To display the collection fields in the data table control, click the Edit fields option and add fields as needed.
Remove Multiple Columns from a Power Apps Collection
  • Now, click on the button control to display the Power Apps collection without unwanted columns as below.
Remove Multiple Columns from the Power Apps Collection

This is how to remove multiple columns from a Power Apps Collection.

Furthermore, you may like some more Power Apps tutorials:

Conclusion

Whenever you want to remove an unwanted column from a Power Apps collection, you can use a DropColumns() function to remove all unwanted columns or a column.

This Power Apps tutorial taught us how to remove a column from Power Apps collection. Then, we discussed using the Power Apps Dropcolumns function to remove a column from the Power Apps collection using a single line of code.

Also, we covered how to remove multiple columns from a Power Apps collection and display the remaining columns on a Data table control with a simple example.