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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bendsteel6
Helper I
Helper I

Create Category Values Based on Another Column Range

I've search the forums and can't find an issue quite like this...but it should be simple.  I simply want to create a "range" column based on a number in another column, in the same way I would a CASE-WHEN statement...

 

case
  when (COUNT(t1.CUST_NAME)) = 1 then "1 Truck"
  when (COUNT(t1.CUST_NAME)) = 2 then "2 Trucks"
  when (COUNT(t1.CUST_NAME)) = 3 then "3 Trucks"
  when (COUNT(t1.CUST_NAME)) = 4 then "4 Trucks"
  when (COUNT(t1.CUST_NAME)) = 5 then "5 Trucks"
  when (COUNT(t1.CUST_NAME)) between 6   and 10   then "6 to 10 Trucks"
  when (COUNT(t1.CUST_NAME)) between 11  and 20   then "11 to 20 Trucks"
  when (COUNT(t1.CUST_NAME)) between 21  and 50   then "21 to 50 Trucks"
  when (COUNT(t1.CUST_NAME)) between 51  and 100  then "51 to 100 Trucks"
  when (COUNT(t1.CUST_NAME)) between 101 and 250  then "101 to 250 Trucks"
  when (COUNT(t1.CUST_NAME)) between 251 and 500  then "251 to 500 Trucks"
  when (COUNT(t1.CUST_NAME)) between 501 and 1000 then "501 to 1000 Trucks"
  else "Over 1000 Trucks"
end

 

I tried creating a conditional column but it doesn't have a 'between' condition.  Is there a better/easier way? 

 

Thanks!

 

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@bendsteel6 ,

 

You may also use SWITCH.

https://community.powerbi.com/t5/Desktop/Creating-groups-based-on-numbers/td-p/196817

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-chuncz-msft
Community Support
Community Support

@bendsteel6 ,

 

You may also use SWITCH.

https://community.powerbi.com/t5/Desktop/Creating-groups-based-on-numbers/td-p/196817

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi,

This solution works just as well as the previous...and a bit less code. 🙂

Anonymous
Not applicable

You can try this as a new column:

 

new column = 

IF(calculate(count(t1.CUST_NAME)) = 1 , "1 Truck",

IF(calculate(count(t1.CUST_NAME)) = 2 , " 2 Trucks",

IF(calculate(count(t1.CUST_NAME)) = 3 , " 3 Trucks",

IF(AND(calculate(count(t1.CUST_NAME)) <= 6, calculate(count(t1.CUST_NAME)) <=10, “6 to 10 Trucks”,"Over 1000 Trucks")))

 

 

Thanks!  Works wonderfully!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.