Value.NullableEquals

Value

Compares two values for equality, returning null if either value is null (three-valued logic).

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Value.NullableEquals(value1 as any, value2 as any, optional comparer as nullable function) as nullable logical

Parameters

NameTypeRequiredDescription
value1anyYesThe first value to compare.
value2anyYesThe second value to compare.
comparerfunctionNoAn optional comparer function for custom equality semantics.

Return Value

logicalTrue if equal, false if not equal, null if either value is null.

Remarks

Value.NullableEquals implements three-valued equality (also called SQL-style equality): when either operand is null, the result is null — not true or false. This matches the behavior of the M = operator when applied to nullable values and mirrors SQL's IS DISTINCT FROM / = null semantics.

The three possible results are:

| value1 | value2 | Result | |--------|--------|--------| | non-null | non-null (equal) | true | | non-null | non-null (different) | false | | null | any | null | | any | null | null |

This contrasts with Value.Equals(null, null) which always returns trueValue.Equals never returns null. Choose between the two based on whether you need null-propagating semantics:

- Use Value.NullableEquals when you want comparisons involving null to return null (propagate unknown), as in SQL WHERE clauses - Use Value.Equals when you want null = null to be definitively true, as in deduplication or record matching

The optional comparer parameter allows custom equality logic (e.g., Comparer.OrdinalIgnoreCase) just like Value.Equals.

Examples

Example 1: Both non-null and equal — returns true

Result
Result
1TRUE

Example 2: One operand is null — returns null

Result
Result
1null

Example 3: Both null — returns null (unlike Value.Equals)

Result
Result
1null

Example 4: Both non-null and unequal — returns false

Value.NullableEquals("hello", "world")
Result
Result
1FALSE

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks