Number.Type

Updated on

Number.Type is a general numeric facet in Power Query M language, representing a specific annotation to the base type ‘type number’. It is used for various mathematical and computational purposes within Power Query M. The base type of ‘type number’ in Power Query is a general numeric type, but facets like Number.Type are essential for diverse numerical operations and calculations in data processing.

Examples

Generally, you will face a facet when transforming column types. You can transform a column into the specified type by using Table.TransformColumnTypes:

Table.TransformColumnTypes( Source, {{ "myColumn", Number.Type }} )

Or when adding a column using Table.AddColumn:

Table.AddColumn( Source, "myColumn", 99, Number.Type" )

To inspect the kind of value you are dealing with, you can make use of the Table.Schema function. Applying it to a table returns a table with information about your columns. The Table.SingleRow function then transforms the result into a record, for easier reading.

let 
  a =  99,
   // Ascribes a type claim facet for 'type number'
  b = Value.ReplaceType( a, Number.Type ),
  // Returns a table containing a value with the ascribed "Number.Type" 
  c = #table(type table [Col1 = Value.Type( b ) ], { b } ), 
  // Shows the Table information, including typeName and value kind
  d = Table.Schema( c ),
  // For easier viewing, return table as record
  e = Table.SingleRow( d )
in 
  e

Related facets

Other related facets are:

BI Gorilla Youtube Channel

Contribute » | Contributors: Rick de Groot