Number.IsOdd Function of Power Query

The Number.IsOdd function returns true if a value is an odd number, otherwise false.

Syntax

Number.IsOdd(number as number) as logical 

Example: Check the given number is an Even or Odd.

Power Query M

let
    Source = Number.IsOdd(5)
in
    Source 

The output of the above code is True.

Example: Check all the values of a column in the table is an even or odd.

Power Query M

let
  MyTable = Table.FromRecords(
    {
      [CustomerID = 1, Name = "Ashish", Marks = 568], 
      [CustomerID = 2, Name = "Katrina", Marks = 855], 
      [CustomerID = 3, Name = "Alia", Marks = 380], 
      [CustomerID = 4, Name = "Vicky", Marks = 458], 
      [CustomerID = 5, Name = "Mohini", Marks = 278], 
      [CustomerID = 6, Name = "Meenakshi", Marks = 289], 
      [CustomerID = 7, Name = "Esha", Marks = 875], 
      [CustomerID = 8, Name = "Anjali", Marks = 380]
    }
  ), 
  #"Return Output" = Table.AddColumn(MyTable, "IsOdd?", (rec) => Number.IsOdd(rec[Marks]))
in
  #"Return Output"  

Note: Here, rec is any name or more technically a parameter representing each row of the table being processed. By using rec[Marks], we are extracting the current record’s Marks column value.

The output of the above code is shown below:

Number.IsOdd function in Power Query