One of the great features of Power Query is the way you can view any rows that contain error values when you load data. However, even if you can see the rows that have errors you can’t see the error messages easily – without writing a little bit of M code, which I’ll show you in this post.
Imagine you have the following table of data:
…and you load it into Power Query using the following query, which sets the data type for the Sales column to be Whole Number:
let Source = Excel.CurrentWorkbook(){[Name="Sales"]}[Content], #"Changed Type" = Table.TransformColumnTypes( Source, {{"Sales", Int64.Type}, {"Product", type text}}) in #"Changed Type"
As you’d expect, the last two rows contain error values as a result of this type conversion:
You can also see the number of rows that contain errors when you load the query:
Clicking on the “2 errors” link in the screenshot above creates a new query that only contains the rows with errors:
You can click on the Error link in any cell that contains one to see the error message:
But what you really want is to see the error message for each row. To do this add a new custom column with the following definition:
try [Sales]
You will then see a new column called Custom containing a value of type Record. You can then click the Expand icon in the column header (highlighted) and then OK:
You’ll then see another column called Custom.Error with an Expand icon; click on it and then click OK again.
And at last you’ll have two columns that show the error messages for each row: