ShowColumns 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.

ShowColumns Function

The ShowColumns function is used to include one or more columns from the data source and drops all other columns. We can use this with controls where we only want a single column table returned from a data source. A common example is the dropdown control.

Power Apps Syntax ShowColumns(Table, ColumnName1 [, ColumnName2, ... ] )

If we wanted to use a data source named 'Teachers Data' to display teacher names from the 'Teacher name' column. We would use the following formula in the Items property of the Dropdown control.

Power Apps Formula

ShowColumns('Teachers Data','Teacher name')
ShowColumns Function in Power Apps

With this formula, the Dropdown control displays the values from the 'Teacher name' column. ShowColumns can also return more than one column.
The following example shows how to add the Expenditure column to our Dropdown control.

Power Apps Formula

ShowColumns('Teachers Data','Teacher name', Expenditure)

The Dropdown control will only display the first column, by default but we will have access to all the retrieved columns, and can show also in the dropdown control using the Value property of the dropdown control

ShowColumns Function in Power Apps

The dropdown will only display the values from only one column, but with the following formula, we can see that when we select any dropdown value, we basically select the entire record, not only that column value. To see that add a Label control to the screen and set the Text value to the following powerapps formula.

Power Apps Formula

Dropdown2.Selected.Expenditure

The formula returns the value from the Expenditure column for the selected row in our Dropdown control. Here, Dropdown2 is the name of our dropdown control.

ShowColumns Function in Power Apps