Table.AddColumn

 

This topic applies to the Power Query Formula Language which can be used with Power Query and Power BI Desktop to build queries that mashup data. See the list of function categories.

Adds a column named newColumnName to a table.

Table.AddColumn(table as table, newColumnName as text, columnGenerator as function,  optional columnType as nullable type) as table  

ArgumentDescription
tableThe Table to modify.
newColumnNameThe name of the new column to add.
columnGeneratorNew column generator function.
optional columnTypeOptional column type for new column

The values for the column are computed using the specified function from each row.

Table.AddColumn(Table.FromRecords(  
  
{  
  
      [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0, Shipping = 10.00],  
  
      [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0, Shipping = 15.00],  
  
      [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0, Shipping = 10.00]  
  
}  
  
), "TotalPrice", each [Price] + [Shipping])  
  
Table.AddColumn(Table.FromRecords(  
  
{  
  
      [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0, Shipping = 10.00],  
  
      [OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0, Shipping = 15.00],  
  
      [OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0, Shipping = 10.00]  
  
}  
  
), "TotalPrice", each [Price] + [Shipping])  

OrderIDCustomerIDItemPriceShippingTotalPrice
11Fishing rod10010110
211 lb. worms51520
32Fishing net251035
Show: