Skip to content
Home » ShowColumns function in Power Apps

ShowColumns function in Power Apps

The ShowColumns function creates a new table including all the columns that you specify and exclude all other columns. It does not modify the original table.

Syntax:

ShowColumnsTableColumnName1 [, ColumnName2, ... ] )
  • Table – Required. This is the source table or data source from which you want to select specific columns.
  • ColumnName(s) – Required. Name(s) of the column(s) you want to include in the new table. You must specify column name with double quotes included.

Here’s an example of how to use the ShowColumns function in Power Apps.




In this example, we are using a SharePoint list named EmpInfo as the data source

In the screenshot below, upon clicking the button, the existing data is cleared, and new data is stored in a collection named Cl_EmpInfo, from source EmpInfo table.
ClearCollect(
Cl_EmpInfo,
EmpInfo
);

Let’s review the data stored in the collection. Go to the Variables tab, expand Collections, and you will see that the collection named Cl_EmpInfo has been created.

Once you click on View Table, you can see the data stored in the collection, which includes all the columns from the source table. Simply scroll to the right to view all the columns.

If you are using a SharePoint list as your data source, you may notice additional columns such as Modified, Created, FullPath, Attachments, IsFolder, and more.

Storing all the columns from the data source in a collection is not advisable, as it can negatively impact app performance.

Whenever you need to store source data in a collection, it is  best to include only the specific columns you require for future use. You can select these specific columns using the ShowColumns function.

Select specific columns from source table using ShowColumns function

Let’s create a collection and store specific columns within it.

In the OnSelect property of the button, enter the following formula. This will create a collection named Cl_EmpInfo that includes only the Name, City, and Country details from the EmpInfo table

ClearCollect(
Cl_EmpInfo,
ShowColumns(
EmpInfo,
"Name",
"City",
"Country"
)
);

Let’s click on button to store data into collection.




Now, let’s check the collection. Go to the Variables tab, expand Collections, and you’ll see that the collection named Cl_EmpInfo has been created

Now, click on View Table to see the data stored in the collection.

You will notice that it contains data only for the specific columns: Name, City, and Country.

The benefit of using ShowColumns is that it allows us to include only the specific columns we want in the table.

As collection is an in-memory database-like table which stores the data in-memory, which may impact app performance when working on large datasets.

Instead of retrieving all columns from the source table, you can select only the necessary columns to store in the collection. This approach not only significantly improves app performance but also enhances data privacy and security by allowing you to exclude sensitive or confidential information from the table

 

Also Read..

Text function to format date/time or numbers to text string

With function in Power Apps

Filter function in Power Apps

LookUp function in Power Apps

 

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SQL BI Tutorials

Subscribe now to keep reading and get access to the full archive.

Continue reading