Search code examples
powerquerym

Power Query How to Assign Values to range of Numbers


I have a range of numbers that I need to assign scores to and would like to see if there's an easy way to do it through Power Query:

   >150 = 0,
101-150 = 1,
 51-100 = 2,
  21-50 = 3,
   <=20 = 4

Thanks in advance


Solution

  • The most obvious way is just an if .. then .. else if .. construction as a new custom column similar to this:

    Score =
    if [value] > 150 then 0
    else if [value] >= 101 and [value] <= 150 then 1
    else if ...
    else if [value] <= 20 then 4
    else null