This PowerApps functions tutorial, we will discuss how to use PowerApps Table() function. How to create a table using the PowerApps Table() function.
Also, we will see how to use GroupBy and Ungroup in PowerApps temporary table and how to create a nested table in PowerApps. Then we will see how to use Filter Function in PowerApps Table. Then we will see how to use PowerApps AddColumns(), DropColumns(), RenameColumns() and ShowColumns() function.
In the above Table function, I have created two records. Each record should be inside the “{}”. The fields of each record should be separated by “,”. We can assign the field value to the field by “:”.
In the above example “ProductName”, “Price”, “Review”, “Quantity” are called fields. Fields are combined called records. The “MI Mobile” is the field value I have assigned to “ProductName” fields.
For a single-column table, we do not need to write the Table() function. We just simply need to mention the column names inside a square bracket and comma after each column’s name. For example [col1,col2,col3,…..].
In the below example I have displayed the temporary table data in a PowerApps Data Table control. First I have added a DataTable control from Insert->Data Table.
After the Data Table is successfully added to the PowerApps screen we will get the “DataTable1” name under the “Screen1” in the left side panel. Select the “DataTable1” and from the property dropdown select “Items” property. In the “Items” property Formula, bar write the below formula
In the DataTable control if you will not get the field then from the right-side panel under “Properties” you will get “Fields”. Select on the “Fields” you will get a Data Panel, you will get all the columns name. Check the columns name which you want to display in the DataTable.
powerapps table function
Create a collection of records in PowerApps Table
Now we will see how to create a collection of records in PowerApps table. Two ways we can create a collection of Table Data.
First Method:
Add a Button control from Insert->Button. Button Control “OnSelect” property write
I have created a variable using the Set() keyword. The Variable name I have given “ProductDetails” and store the Table records. When we will click on the button the table records will save to the variable name.
powerapps table function
I have created one more button control. On the button “Onselect” property I have written “ClearCollect(DemoTable,ProductDetails)”. “DemoTable” is the collection name. I have assigned the variable name to the Collection name. When we will click on the button the collection will be created.
powerapps table function
We can check the collection from the View->Collection.
powerapps collection function
Second Method:
Without using the variable name also we can create a collection. Just add one more button control “Onselect” property write the below rule.
Display First record’s Field Value from PowerApps Table
We will see now how to display the ProductName column first record value. So I have added a Dropdown control from Insert -> Controls -> Dropdown.
On the Dropdown control Items property, I have added the rule “First(ProductDetails.ProductName)“. So in the dropdown, we will get the “MIMobile” value.
powerapps table function
GroupBy and Ungroup PowerApps Temporary Table
We will see now what is PowerApps GroupBy() and Ungroup() function. The GroupBy() method is used to group a set of records based on one or more columns. Ungroup() method is used to ungroup the grouped items. We can understand better from the below example.
GroupBy():
I have added a button control set its text property to “TableVariable”. On the button “Onselect” I have written
I have just created a table and stored the table value in an EmpDept variable name.
Now we will create a collection on a but “Onselect” property where we will store the Table value. So I have used the ClearCollect function and stored the variable name.
ClearCollect(EmployeeDepartment,EmpDept)
For “Group By” I have added one more button. Set the button text property to “GroupBy”. On the button control text propety, I have added
I have grouped the “Name” column based on the “Department” column. Inside the “groupBy” method I have passed the table variable name and columns name. I have stored the grouped item inside a collection. My collection name is “DepartmentCollection”.
groupby in powerapps
Now we will check our output from View->Collections.
powerapps groupby collection
powerapps groupby collection
Ungroup():
Below is how we can use ungroup() function in PowerApps.
I have created a Table and stored the “Product” field value and inside the table I have created one more table and added some record value. Then I have stored the Table value in a collection named as “ProductDetails”.
powerapps nested table
We will get the collection from “View” tab->Collections. The Mobile Details contains a sub table.
powerapps nested table
When we will click on the “Table” icon we can see the sub-table all the records.
powerapps nested table
Embedded First() formula inside Table() in PowerApps
In the below example I have added a “First()” function inside the Table function. I have added a DataTable Control and on Its Item property I have added the below rule
From the DataTable->right side panel(properties)->Fields. Check the field name.
In the above rule, I have added a Table() function. Inside the table function, I have written the First(). Add the Table value stored “variable name. the column name”.
powerapps first function
Filter Function in PowerApps Table()
We will see how to use the filter function for PowerApps temporary table. First I have added a button control. Set its text property to “Create Table”. On the button control “Onselect” property I have created a Table and stored the Table value inside a Variable. The variable name is “StudentMarkSheet”.
Now I have added a Gallery control. Set its “Items” property to
Filter( StudentMarkSheet, Mark > 250 )
The Filter function will filter the “StudentMarkSheet” Table, where Mark column is more than 250. In the Gallery control, we will get the StudentName whose mark is more than 250.
powerapps filter function in table values
PowerApps AddColumns(), DropColumns(), RenameColumns() and ShowColumns() function
AddColumns:
I have added one more Gallery control. Set its Items property to
using AddColumns function we can add a new column in Table. In the below screenshot I have added a new column named as “Percentage” in the “StudentMarkSheet” Table. I have stored the “Mark/Total*100” value in the “Percentage” columns.
In the Gallery, control chooses “Title, Subtitle and Body” layout. Select on the body label on the label text property write “ThisItem.Percentage”.
powerapps add columns
ShowColumns:
Using The ShowColumns() we can display the selected columns in the PowerApps Control. Here I have created a DataTable, on the DataTable “Items” property I have written:
In the below example I have added the new percentage columns and Name columns inside the ShowColumns().
powerapps show columns
RenameColumn(): Using the RenameColums() we can change the Tables old column name to new column name. So I have added the below rule in the DataTable Items property.
DropColumn(): The DropColumns() is used to delete the column from the Table. In the below example I have added a “DataTable” control and in its Items property I have written:
DropColumns( StudentMarkSheet, "TotalMark")
I have deleted the “TotalMark” column. So in the DataTable fields property, we will not get the “Totalmark” column.