Check a Value's Data Type at Runtime in Power Query M

Inspects the actual type of a value or column, useful for debugging unexpected type errors.

Data TypesIntermediatetypedebugvalue.type

Power Query M code

let
    Source = YourTable,
    AddedTypeCheck = Table.AddColumn(Source, "ColumnType", each Value.Type([ColumnName]), type type)
in
    AddedTypeCheck

Notes

Remove this helper column once you've confirmed the type - it's a debugging step, not something to ship in a production query.

Requirements

How to use this snippet

  1. In Power BI Desktop, choose Transform data to open Power Query, then open the Advanced Editor on a query (or start from a blank query).
  2. Paste the snippet and replace the placeholder names (tables, columns, file paths) with your own. Check the requirements above first.
  3. Run it through the Power Query M Formatter to tidy the layout.

Related Power Query M snippets

More Power Query M resources

Browse all 145 snippets in the Power Query M Code Snippets, or search the library for something similar to Check a Value's Data Type at Runtime.