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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
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.