DropColumns functions in Power Apps
The AddColumns, DropColumns, RenameColumns, and ShowColumns functions in Power Apps are used to shape the table by adding, dropping, renaming, and selecting its columns. All these functions, results in a new table, but note that the original table that is our data source is not modified at all by these functions.
DropColumns Function
The DropColumns function is used to remove columns from the table within Power Apps and returns the table with the rest columns. But it does not modify the original data source.
Power Apps Syntax DropColumns(Table, ColumnName1 [, ColumnName2, ... ] )
The function has the following parameters:
- Table – It is a required parameter. It specifies a data source, may be Sharepoint list, collection or any tabular data source on which we are going to perform the operation.
- ColumnName(s) - It is a required parameter. It specifies the name(s) of the column(s) to drop. Please note the column name should be in single quotes if the column name has space in its name otherwise, we can omit the single quotes (for example, Name and ‘Total Marks’).
Power Apps Formula
The above formula will write the contents of the data source, 'Teachers Data', to the collection variable, MyDropCollection, after dropping the columns 'Teacher salary' and Expenditure.
The MyDropCollection is used in the Items property of the Gallery control, as shown in the image below:
In the above image we can see that the ‘Teacher salary’ and Savings fields are giving errors as both are not available in the table anymore. Because ‘Teacher salary’ is dropped by the DropColumns function and Savings column is functionally added to the collection, MyCollection, by using the AddColumns function, as it is not present in the original datasource.