Justin
Justin

Reputation: 11

How to sum two columns in a third column in PowerApps table

    Table({
        orderDate: "Lenovo Thinkpad",
        orderId: "Procurement",
        ordererValue: 10,
        customer: "499.99",
        customerEmail: orderValue * customer)
}
)

Picture

How to sum two columns in a third column in PowerApps table?

Upvotes: 0

Views: 1360

Answers (2)

carlosfigueira
carlosfigueira

Reputation: 87308

Another alternative to Ganesh's solution is to use the AddColumns function, which returns a table with additional columns. If you have

Table({
    orderDate: "Lenovo Thinkpad",
    orderId: "Procurement",
    ordererValue: 10,
    customer: "499.99")
})

You can get the extra column with

AddColumns(
  Table({
    orderDate: "Lenovo Thinkpad",
    orderId: "Procurement",
    ordererValue: 10,
    customer: "499.99")
  }),
  "customerEmail", orderValue * customer)

You can also save the result of AddColumns in a collection to manipulate it later:

ClearCollect(
  allOrders,
  AddColumns(
    Table({
      orderDate: "Lenovo Thinkpad",
      orderId: "Procurement",
      ordererValue: 10,
      customer: "499.99")
    }),
    "customerEmail", orderValue * customer))

Upvotes: 0

Ganesh Sanap - MVP
Ganesh Sanap - MVP

Reputation: 2238

You can use formula in below format to get the sum of two columns in table and save in third column:

ForAll(
   YourDataSourceName As aPatch,
   Patch(
      YourDataSourceName,
      {orderId: aPatch.orderId},
      {ThirdColumn: aPatch.orderValue + aPatch.customer}
   )
)

Reference: Sum of two columns in third column


Update:

First of all, store your table data in one collection like:

ClearCollect(
    colTableData,
    Table(
        {
            orderDate: "Lenovo Thinkpad",
            orderId: "Procurement",
            ordererValue: 10,
            customer: "499.99",
            customerEmail: orderValue * customer
        }
    )
)

Then you can get sum like:

ForAll(
   colTableData As aPatch,
   Patch(
      colTableData,
      {orderId: aPatch.orderId},
      {customerEmail: aPatch.orderValue + aPatch.customer}
   )
)

Upvotes: 1

Related Questions