Live Developer Training: next batch coming soon. Be the first to know.Live training: next batch soonJoin the waitlist →Join →

How to Add Column in Power Apps Collection?

Are you new to Power Apps and waiting to learn how to add column in Power Apps Collection? No worries!

This Power Apps tutorial will teach all the information about Power Apps AddColumns() and how to add a column in the Power Apps collection.

Here, we will discuss how to add a column to an existing Power Apps collection or add a column from another Power Apps collection.

Power Apps AddColumns()

Power Apps AddColumns() function helps to add a column to a table or collections and a formula defines the values in that column.

Syntax:

AddColumns( Table, ColumnName1, Formula1 [, ColumnName2, Formula2, ... ] )

Where,

  • Table = Specify the Table to operate on.
  • ColumnName(s) = It is Required. Provide the Name(s) of the column(s) to add. You must specify a string for this argument.
  • Formula(s) = Specify the Formula(s) to evaluate for each record. The result is added as the value of the corresponding new column.

How to Add Column in Power Apps Collection

Now, we will see how to add a column in the Power Apps collection with a simple example.

Example 1:

I have a Power Apps collection named “colProductDetails” containing the below columns.

How to Add Column in Power Apps Collection

I would like to add a column [TotalAmount] in the collection using the AddColumns() function, as in the screenshot below.

How to Add Column in Power Apps Collection

To work around this example, follow the below steps. Such as:

1. Create a Blank canvas app -> Select Power Apps Screen [ProductDetailsScreen] and set Its OnVisible property to the code below.

OnVisible = ClearCollect(
    colProductDetails,
    {
        ProductID: "SP001",
        ProductName: "Torch",
        Color: "Red",
        Quantity: 2,
        Price: 500
    },
    {
        ProductID: "SP002",
        ProductName: "Rice cooker",
        Color: "White",
        Quantity: 5,
        Price: 2000
    },
    {
        ProductID: "SP003",
        ProductName: "Mobile Phone",
        Color: "Black",
        Quantity: 4,
        Price: 3000
    },
    {
        ProductID: "SP004",
        ProductName: "Digital camera",
        Color: "Brown",
        Quantity: 2,
        Price: 1000
    },
    {
        ProductID: "SP005",
        ProductName: "Mixer",
        Color: "Grey",
        Quantity: 3,
        Price: 1500
    }
);

Where,

  • colProductDetails = Power Apps Collection Name
  • ProductID, ProductName, etc… = Collection Headers/Columns
  • “SP001”, “Torch”, “Red”, etc… = Collection Records/Rows
Add a Column in Power Apps Collection

2. I want to add another column in the collection using this source collection. To do so, use this collection in the Screen’s OnVisible property, as shown below.

OnVisible = ClearCollect(
    colAddColumn,
    AddColumns(
        colProductDetails,
        "TotalAmount",
        ThisRecord.Quantity * ThisRecord.Price
    )
)

Where,

  • colAddColumn = New collection name
  • AddColumns() = This function helps to add a column to a table or collections
  • colProductDetails = Power Apps source collection
  • “TotalAmount” = New column name
  • ThisRecord.Quantity * ThisRecord.Price = We can multiply these two columns to get new column records
How to Add a Column in Power Apps Collection

3. Save, Publish, and Reload the app to get this collection. Then, insert a Data table to display the Power Apps collection and set its Items property as:

Items = colAddColumn
Add Column in the Power Apps Collection

4. Next, to display the collection fields on a data table, click the Edit fields option, choose your respective fields, and click the Add button below.

Add a Column in the Power Apps Collection

5. Once, you added collection fields, the data table will display all the records with respective columns.

How to Add Column in the Power Apps Collection

6. If you want to find the final collection, go to the Variables section, click the Collections drop-down, and select a respective collection [colAddcolumn] like below.