The big news this week – at least for me – was the release of the new Power Query data types to the Excel insiders channel. You can read all about it here:
https://insider.office.com/en-us/blog/power-query-data-types-in-excel
They’re the latest manifestation of Excel linked data types; cool things are also happening with them and Power BI featured tables too.
The announcement blog post explains pretty much everything you can do right now with Power Query data types but I was curious about the M code that is used to create them. Here’s an example query that takes this source table:
…and creates this Power Query data type:
let Source = #table( type table[ Fruit = text, Colour = text, Sales = number ], { {"Apples", "Green", 10}, {"Lemons", "Yellow", 20}, {"Strawberries", "Red", 30} } ), #"Created data type" = Table.CombineColumnsToRecord( Source, "Data type", {"Fruit", "Colour", "Sales"}, [DisplayNameColumn = "Fruit", TypeName = "Excel.DataType"] ) in #"Created data type"
The magic happens with the #”Created data type” step and the Table.CombineColumnsToRecord function; so Power Query data types are basically columns that contain record values with (I guess, I need to check) some extra metadata.