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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
KAmorris
Frequent Visitor

Sorting a visual by calculated measure with text and numbers

Hi!

 

I'm so grateful for the help that has been provided to me on this forum.  I was wondering if someone had some thoughts about one more issue I've come across. 

 

I've been using a calculated measure to represent responses. The measure essentially counts the number of people who indicated a certain response (for example, a certain type of disability or health condition) UNLESS less than 15 people (but more than 0) selected that response. In that case, the text "<15" would appear.

 

The measure I've been using: 

 

Count(<15) =
SWITCH (
True(),
DISTINCTCOUNT(Table[Response_ID])>=15,DISTINCTCOUNT(Table[Response_ID]),
DISTINCTCOUNT(Table[Response_ID])=0, 0,
DISTINCTCOUNT(Table[Response_ID]) <15,"<15")
 
The issue:
I'd like to sort the visual that I created using this measure by count. If I sort by descending, the table looks something like this:
 
Disability or Health ConditionNumber of Responses
Disability1<15
Disability2<15
Disability3<15
Disability426
Disability522
Disability60

 

I would like the table to appear as:

 

Disability or Health ConditionNumber of Responses
Disability426
Disability522
Disability1<15
Disability2<15
Disability3<15
Disability60

 

Any tips or suggestions would be so appreciated! Thanks in advance!

1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@KAmorris ,

See attached.  I revised the file you sent me.

View solution in original post

2 REPLIES 2
rsbin
Super User
Super User

@KAmorris ,

See attached.  I revised the file you sent me.

Keith-Sayer
Resolver I
Resolver I

The problem is you are trying to sort both strings and number fields.

 

I think the easiest way to do this would be to just add an intermediate column where you return the "actual" value for all responses (including the <15 ones), then sort based on that column, even though your user is going to use the calculated one with the <15 logic attached.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.