Power Query Value.Equals: How to Compare Values
In this article
Value.Equals is a Power Query M function that returns true if two values are equal, and false otherwise. It is the explicit, type-aware comparison function you use when you need a reliable boolean result in a custom column, a filter step, or a conditional expression. Unlike the = operator, Value.Equals handles nulls and mixed types in a defined way, which makes it the safer choice for data cleaning and validation logic.
What You'll Need
- Power Query Editor open in Excel, Power BI Desktop, or another host that supports M queries.
- A table or query with at least two values or columns you want to compare.
- Basic familiarity with adding a custom column or editing the formula bar.
Step-by-Step
- Load your data into Power Query. In Excel, select your table and choose Data > From Table/Range. In Power BI Desktop, choose Home > Transform data to open the Power Query Editor. The exact menu labels can differ slightly by version, device, or region.
- Decide where the comparison belongs. For a new result column, use Add Column > Custom Column. To filter rows, use the filter icon on a column header and choose a condition, or add a step in the formula bar. To test a single value in a step, you can edit the M code directly.
- Write the Value.Equals expression. The syntax is
Value.Equals(value1, value2). For example, to compare the [Status] column to the text "Active", enterValue.Equals([Status], "Active"). The function returns a logical true or false. - Use it in a conditional column. In the Custom Column dialog, you can wrap it:
if Value.Equals([Status], "Active") then "Yes" else "No". This converts the boolean into readable text. - Compare numbers and dates correctly. Value.Equals is type-aware. Comparing the number 5 to the text "5" returns false. If your column is text but contains numbers, convert it first with Table.TransformColumnTypes or Number.From. For dates, compare date values, not text representations.
- Handle nulls deliberately. Value.Equals(null, null) returns true. Value.Equals(null, "") returns false. If you want to treat null and empty text as equal, write an explicit condition:
Value.Equals([Col1], [Col2]) or (List.Contains({null, ""}, [Col1]) and List.Contains({null, ""}, [Col2])). Keep it simple unless the business rule requires it. - Apply the step and check the result. Click OK. Review the new column or filtered rows. If the result is unexpected, click the step in the Applied Steps pane and inspect the formula in the formula bar.
- Test edge cases. Create a small query with known values: a number, a text number, a null, an empty string, and a date. Compare each pair and confirm the boolean matches your expectation. This catches type mismatches before they reach your report.
Common Mistakes
- Assuming = and Value.Equals behave identically. The = operator can coerce types in some contexts; Value.Equals does not. Use Value.Equals when you need strict, predictable comparison.
- Comparing text to numbers without converting. A column that looks numeric may still be type text. Value.Equals("5", 5) is false. Convert the column type first.
- Forgetting that null is a value. Value.Equals(null, null) is true, which can surprise you in filters. Decide whether nulls should match before you write the expression.
- Using it for case-insensitive text comparison without checking. Value.Equals is case-sensitive for text. If you need case-insensitive matching, normalize with Text.Lower on both sides first.
- Placing the function in the wrong step. Adding a custom column creates a new step; editing an existing step can change earlier results. Work on a copy of the query if you are unsure.
Tips
- Use Value.Equals inside
ifexpressions to produce clean labels instead of raw true/false values. - For comparing entire rows, combine multiple Value.Equals calls with
and, or use Table.SelectRows with a record comparison if your data model supports it. - Keep a small "test" query with known values. It is faster to debug a five-row query than a fifty-thousand-row one.
- When comparing floating-point numbers, exact equality can fail due to rounding. Round both sides first with Number.Round if the business rule allows it.
- Document the comparison logic in the step name (for example, "Compare Status to Active") so the next person understands the intent.
Troubleshooting
If Value.Equals returns false when you expect true, check the column data types first. In Power Query, the type icon next to the column header shows the current type. A column showing "ABC" is text, even if it contains digits. Use Transform > Data Type to change it, then re-run the comparison.
If you see an error like "We cannot convert the value null to type Text", one of the arguments is null and the function expects text. Wrap the expression with a null check or replace nulls with a placeholder using Table.ReplaceValue before comparing.
If the custom column dialog rejects your formula, verify the function name is spelled exactly Value.Equals with a capital V and E, and that you have closed all parentheses. M is case-sensitive for function names.
If the comparison works in the editor but fails after loading to the worksheet or data model, check whether the query is folding to a source that does not support the function. In that case, add a step that forces local evaluation, such as Table.Buffer, but use it sparingly because it can increase memory use.
If results differ between Excel and Power BI, confirm both are using the same query and that no step was added or removed during load. The function itself behaves the same across hosts.
Frequently Asked Questions
Is Value.Equals case-sensitive?
Yes, for text values. "Active" and "active" are not equal. Use Text.Lower or Text.Upper on both sides if you need case-insensitive comparison.
How is Value.Equals different from the = operator?
Value.Equals performs a strict, type-aware comparison and returns a logical value. The = operator is used in expressions and can behave differently with type coercion. For explicit equality tests, Value.Equals is clearer.
Can Value.Equals compare dates and times?
Yes, as long as both values are date, datetime, or time types. Comparing a date to a text string that looks like a date returns false. Convert the text to a date first.
Does Value.Equals work with null?
Yes. Value.Equals(null, null) returns true. Value.Equals(null, "") returns false. Handle nulls explicitly if your rule treats them as equivalent to empty text.
Can I use Value.Equals to compare two columns in a custom column?
Yes. For example, Value.Equals([Column1], [Column2]) returns true when the two column values are equal. You can then filter or transform based on that result.
Why does Value.Equals return false for numbers that look the same?
One value is likely stored as text and the other as a number. Check the column type icons and convert the text column to a number before comparing.