Search code examples
functiontypespowerbimetadatapowerquery

PowerQuery: How to get Column type?


How to get type for specified ColumnName in Table?

Example: How to get type text for column FirstName: enter image description here

Table code:

= Table.FromRows(
        {
            {1, "Bob", "Smith", "123-4567"},
            {2, "Jim", "Brown", "987-6543"},
            {3, "Paul", "Wick", "543-7890"}
        },
        {"CustomerID", "FirstName", "LastName", "Phone"}    
    )

P.S. Solution as function strongly appreciated! :)

Related Topics:

  1. PowerQuery: How to get Column type?
  2. Powerquery: how to convert/cast type Type to type Text?
  3. PowerQuery: type definition, difference between Table.Scema fields [TypeName] and [Kind]

Solution

  • Use combination of Type.TableColumn and Value.Type functions:

    Type.TableColumn(Value.Type(TableName),ColumnName)