ExtraValues.Error

Updated on

ExtraValues.Error (1) is an enumeration that specifies the expected action for extra values in a row that contains columns more than expected. It is a member of the ExtraValues.Type and indicates that an error should be raised when extra columns are present.

Examples

When it comes to demonstrating the application of the ExtraValues.Error enumeration, the Table.FromList function in Power Query M language is an excellent illustration. This function is capable of creating a table with several columns from a list of Records input.

Take a look at the example below for clarity. It presents two records embedded within a list. Notice how the first record contains two columns, while the second has three. Key for this example is that the ‘type table’ argument specifies only two records. This arrangement results in an ‘extra value’ in the record containing three columns — a value that isn’t anticipated by the function.

The Table.FromList function has an optional fourth argument to provide the ExtraValue.Type. It instructs Power Query on how to handle ‘extra values’. When ExtraValues.Error is specified, Power Query responds by generating the error: DataFormat.Error: There were more columns in the result than expected.

Table.FromList(
   { 
     [ Key = 1, Prod = "Apple" ], 
     [ Key = 2, Prod = "Prume", Id = "Pr" ] 
   }, 
   Record.FieldValues, 
   type table [ ProductKey = Int64.Type, Product = Text.Type ], 
   null, 
   ExtraValues.Error
)
ExtraValues.Error shows an error when excess columns are supplied

In other words, the enumeration ExtraValues.Error effectively prevents unexpected inflation of columns, keeping your table structure consistent and error-free.

Other related enumerations are:

Applies to

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

BI Gorilla Youtube Channel

Contribute » | Contributors: Rick de Groot