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
TriciaECIU
New Member

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 a new column that gives a text output based on a number range in another column.

 

So, where column 1's value is between:

  • 0 and 9, column 2 should show 'very low' in the corresponding row
  • 10 and 30,  column 2 should show 'low' in the corresponding row
  • 31- 50, column 2 should show 'medium-low' in the corresponding row
  • 51-60, column 2 should show 'Medium' in the corresponding row
  • 61-70, column 2 should show 'Medium-high' in the corresponding row
  • 71-90, column 2 should show 'High' in the corresponding row
  • 91-100, column 2 should show 'Very low' in the corresponding row

I am thinking it is a ValueLookUp statement? But not sure of the syntax.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@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"
  )

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
TriciaECIU
New Member

@Greg_Deckler Thank you!

Greg_Deckler
Super User
Super User

@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"
  )

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors
Top Kudoed Authors