Value.Compare

Updated on

Value.Compare is a Power Query M function that compares two input values and returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second one. The function returns an integer indicating the comparison result between the two input values.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Value.Compare(
   value1 as any,
   value2 as any,
   optional precision as nullable number,
) as number
Argument Attribute Description
value1
value2
precision optional The Precision.Type specifies the accuracy level for calculations. When omitting this argument, Power Query uses Precision.Double by default, which, while efficient, may cause rounding errors with very small fractions. For greater accuracy Precision.Decimal offers a more precise number representation, ideal for tasks requiring high precision.

Description

Returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second.

Learn more about Value.Compare in the following articles:

Other functions related to Value.Compare are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/value-compare