MissingField.Error

Updated on

MissingField.Error (0) is an enumeration that specifies the expected action for missing values in a row that contains columns less than expected. It is a member of the MissingField.Type and represents an optional parameter in record and table functions indicating that missing fields should result in an error. (This is the default parameter value.)

Examples

Let’s walk through an easy-to-understand scenario with the MissingField.Error enumeration in the Power Query M Language. Consider this dataset.

Missingfield.Type dataset

You’re deciding which columns are useful and Table.SelectColumns lets you handpick the columns you need.

Table.SelectColumns with a missing column

However, be careful! If you request a column that doesn’t exist, Power Query will flag it immediately and throws an error.

Missingfield.Type demonstrating Table.SelectColumns

The default behavior of Power Query is to use the MissingField.Error enumeration. You can also explicitly provide it by writing it in the optional argument.

Missingfield.Type returning Missingfield.Error
= Table.SelectColumns( Source, { "Name", "Year" }, MissingField.Error )

In this instance, we’re selecting “Name” and “Year” from the source table. If these columns aren’t there, Power Query will raise an error, stopping you from building on a faulty foundation. It’s a useful safeguard, ensuring the integrity of your data processing.

Other related enumerations are:

Applies to

Here’s a list of functions that work with MissingField.Type:

Contribute » | Contributors: Rick de Groot