Value.Compare Function of Power Query
The Value.Compare function returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second.
Syntax
Value.Compare(value1 as any, value2 as any, optional precision as nullable number) as number
Example:
Power Query M
let
MyTable = Table.FromRecords(
{
[EmployeeID = 1, Name = "Ashish", Science_Marks = 56, Math_Marks=65],
[EmployeeID = 2, Name = "Katrina", Science_Marks = 64, Math_Marks=65],
[EmployeeID = 3, Name = "Alia", Science_Marks = 38, Math_Marks=65],
[EmployeeID = 4, Name = "Vicky", Science_Marks = "Fail", Math_Marks="Fail"],
[EmployeeID = 5, Name = "Mohini", Science_Marks = 28, Math_Marks=65],
[EmployeeID = 6, Name = "Meenakshi", Science_Marks = 29, Math_Marks=65],
[EmployeeID = 7, Name = "Esha", Science_Marks = "Pass", Math_Marks="Pass"],
[EmployeeID = 8, Name = "Anjali", Science_Marks = 38, Math_Marks=38]
}
),
return = Table.AddColumn(MyTable, "Equal Check", (_) => Value.Compare(_[Science_Marks],_[Math_Marks]))
in
return The output of the above code is shown below:
