Forum Discussion

TriciaECIU's avatar
TriciaECIU
New Member
2 years ago
Solved

Creating a new text colum based on a number range in another column

Hi all, new Powerbi user here,   I have been trying to find this via the forums, and many a re similar, but different enough to make the solutions not viable for me (I think).   I want to create ...
  • Greg_Deckler's avatar
    2 years ago

    TriciaECIU

    It's PowerQuery so it is just nested if then else statements:

    if [Column] >= 0 and [Column] <= 0 then "Very Low" else if [Column] >= 10 and [Column] <= 30 then "Low" else ...

    DAX would be cleaner. SWITHC(TRUE(), ...) is your friend here:

    Column = 
      SWITCH(TRUE(),
        [Column] >= 0 && [Column] <= 9, "Very Low",
        [Column] >= 10 && [Column] <= 30, "Low",
        [Column] >= 31 && [Column] <= 50, "Medium-Low",
        [Column] >= 51 && [Column] <= 60, "Medium",
        [Column] >= 61 && [Column] <= 70, "Medium-High",
        [Column] >= 71 && [Column] <= 90, "High",
        "Very High"
      )