Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
powerbiepicfail
New Member

IF, THEN statement problems

Hi All,

 

I have two columns, one with fixed numbers between 0-100 [rating] and another new column [RatingGroup] where I want the values to be based on a group of the fixed numbers (e.g. 0 for 0-10, 1 for 10-20 etc.) 

 

I've been trying to break it down to something simple first like this but it's not working:

 

RatingGroup = If(table[Rating] = "0-10", THEN table[RatingGroup] = "0") 

 

Really appreciate some help!

  

Thanks!

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

RatingGroup =
SWITCH (
    TRUE (),
    Table[Rating] >= 0 && Table[Rating] <= 10, "0",
    Table[Rating] > 10 && Table[Rating] <= 20, "1",
    Table[Rating] > 20 && Table[Rating] <= 30, "2",
    Table[Rating] > 30 && Table[Rating] <= 40, "3",
    Table[Rating] > 40 && Table[Rating] <= 50, "4",
    Table[Rating] > 50 && Table[Rating] <= 60, "5",
    Table[Rating] > 60 && Table[Rating] <= 70, "6",
    Table[Rating] > 70 && Table[Rating] <= 80, "7",
    Table[Rating] > 80 && Table[Rating] <= 90, "8",
    "9"
)

This should work Smiley Happy

View solution in original post

2 REPLIES 2
Sean
Community Champion
Community Champion

RatingGroup =
SWITCH (
    TRUE (),
    Table[Rating] >= 0 && Table[Rating] <= 10, "0",
    Table[Rating] > 10 && Table[Rating] <= 20, "1",
    Table[Rating] > 20 && Table[Rating] <= 30, "2",
    Table[Rating] > 30 && Table[Rating] <= 40, "3",
    Table[Rating] > 40 && Table[Rating] <= 50, "4",
    Table[Rating] > 50 && Table[Rating] <= 60, "5",
    Table[Rating] > 60 && Table[Rating] <= 70, "6",
    Table[Rating] > 70 && Table[Rating] <= 80, "7",
    Table[Rating] > 80 && Table[Rating] <= 90, "8",
    "9"
)

This should work Smiley Happy

You are a life savior thank you!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.