Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query Value.NullableEquals: How to Use It

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Value.NullableEquals is a Power Query M function that compares two values and returns true if they are equal, treating null as a valid value that can be compared. Unlike the standard equality operator (=), which returns null when either side is null, Value.NullableEquals returns a logical true or false, making it useful for conditional logic where nulls are expected. You do not need any special setup—just a Power Query editor in Excel, Power BI, or another tool that supports M. The function is available in all current versions, though exact menu labels may vary slightly by version, device, or region.

What You'll Need

  • Access to Power Query (Excel 2016+, Power BI Desktop, or Power Query Online).
  • Basic familiarity with the Power Query Editor and the M formula language.
  • A dataset that contains null values, or a willingness to create a small test query.

Step-by-Step

  1. Open Power Query Editor. In Excel, go to Data > Get Data > Launch Power Query Editor. In Power BI Desktop, click Transform Data on the Home ribbon. The exact path may differ slightly by version.
  2. Create or load a query. You can use an existing query or create a blank query: Home > New Source > Blank Query. This gives you a place to experiment without affecting your data.
  3. Open the Advanced Editor. With your query selected, go to Home > Advanced Editor. This is where you write M code directly. If you are not comfortable with M, you can also use the formula bar, but the Advanced Editor gives full control.
  4. Write a basic Value.NullableEquals expression. Replace the existing code with something like:
    let Source = Value.NullableEquals(1, 1) in Source
    Click Done. The result will be true. Try changing one argument to null: Value.NullableEquals(1, null) returns false.
  5. Compare with the standard equality operator. In a new step, test 1 = null. You will see it returns null, not false. This illustrates why Value.NullableEquals is useful: it always returns a logical value, never null.
  6. Use it in a conditional column. Suppose you have a table with a column “Status” that may contain nulls. Add a custom column (Add Column > Custom Column) with a formula like:
    if Value.NullableEquals([Status], "Active") then "Yes" else "No"
    This safely handles nulls without errors.
  7. Apply it to compare two columns. Create a custom column that checks if two columns are equal, even when both are null:
    Value.NullableEquals([Column1], [Column2])
    This returns true if both are null, which is often desired when checking for matching records.
  8. Test with different data types. Value.NullableEquals works with numbers, text, dates, and logical values. Try comparing a date and a null, or two nulls. Two nulls return true. A null and any non-null value return false.
  9. Handle errors gracefully. If you pass an error value (e.g., from a failed conversion), Value.NullableEquals will propagate the error. Wrap it in try ... otherwise if needed.
  10. Close and load. Once your query works as expected, click Close & Load (or Close & Apply in Power BI) to apply the changes to your workbook or model.

Common Mistakes

  • Assuming Value.NullableEquals is the same as =. The = operator returns null when either operand is null; Value.NullableEquals returns false (or true if both are null). Mixing them up leads to unexpected nulls in filters.
  • Forgetting that two nulls are equal. Some users expect null = null to be false, but Value.NullableEquals(null, null) returns true. This is by design.
  • Using it with incompatible types. Comparing a number to a text value returns false, not an error, but it may hide data quality issues. Ensure types match before comparing.
  • Not handling errors. If an argument is an error, the function returns an error. Use try to catch it if your data may contain errors.
  • Typing the function name incorrectly. M is case-sensitive: Value.NullableEquals is correct; value.nullableequals will fail.

Tips

  • Use Value.NullableEquals in filters to keep or remove null rows explicitly. For example, Table.SelectRows(Source, each Value.NullableEquals([Column], null)) keeps only nulls.
  • Combine with List.Contains for multiple comparisons: List.Contains({"A", "B"}, [Column]) handles nulls differently, so test carefully.
  • For simple equality checks where nulls are not expected, the = operator is faster and simpler. Reserve Value.NullableEquals for cases where nulls are possible and you need a boolean result.
  • Document your custom columns with comments (//) to remind yourself why you used Value.NullableEquals instead of =.
  • Test with a small sample of data before applying to large tables to avoid performance surprises.

Troubleshooting

If Value.NullableEquals does not behave as expected, check the following:

  • Result is null instead of true/false: Ensure you are actually calling Value.NullableEquals and not the = operator. Also check that neither argument is an error value.
  • Function not recognized: Verify spelling and capitalization. In the Advanced Editor, the function name must be exact. If you are using an older version of Power Query, the function may not exist; update your tool.
  • Unexpected false when values look equal: Data types may differ (e.g., text "1" vs number 1). Use Value.FromText or change the column type before comparing.
  • Error message about type mismatch: Some combinations of types (e.g., comparing a record to a number) may raise an error. Ensure both arguments are of comparable types.
  • Performance issues: If used in a custom column over millions of rows, it may slow down refresh. Consider filtering nulls earlier or using simpler logic if possible.
  • Still stuck: Simplify your query to a single step that calls the function with literal values. If that works, the issue is with your column references or data types.

Frequently Asked Questions

What is the difference between Value.NullableEquals and the = operator?

The = operator returns null if either operand is null, while Value.NullableEquals always returns true or false, treating null as a comparable value.

Does Value.NullableEquals consider two nulls equal?

Yes, Value.NullableEquals(null, null) returns true.

Can I use Value.NullableEquals with text values?

Yes, it works with any value type, including text, numbers, dates, and logicals.

What happens if I pass an error value to Value.NullableEquals?

The function returns an error. Use try ... otherwise to handle it.

Is Value.NullableEquals available in all versions of Power Query?

It is available in current versions of Excel, Power BI Desktop, and Power Query Online. Very old versions may not include it.

Can I use Value.NullableEquals in a calculated column in Power BI?

Yes, but only within Power Query (M), not in DAX. For DAX, use the == operator or ISBLANK functions.