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
thrillhouse
Helper I
Helper I

Using Range Bins as Legend Categories

Hello, I am trying to use ranges that I've created from a nother calculated field.  I am taking a distinct count of certain categories and then I've created a range out of this distinct count:

 

Main Categories Count =
CALCULATE (
DISTINCTCOUNT ( [Category]),
[Category] = "Cat1"
|| [Category] = "Cat2"
|| [Category] = "Cat3"
|| [Category] = "Cat4"
|| [Category] = "Cat5"
)
 
 
Range Bins =
IF (
[Main Categories Count] < 3,
"0-2",
IF (
[Main Categories Count] >2
&& [Main Categories Count] <5,
"2-4",
IF ( [Main Categories Count] > 4, "5+")
)
)
 
I'm unable to make this function properly as a legend.  The only value that displays in the legend is the first bin (0-2).  The field is working properly as I can see the bins displaying properly in a table, however, it just doesn't want to work as a legend.
 
Any help is greatly appreciated!
 
Thanks!
4 REPLIES 4
v-angzheng-msft
Community Support
Community Support

Hi, @thrillhouse 

 

Could you please consider sharing more details about it and posting expected result so it is clear on what needs to be implemented?  And It would be great if there is a sample file without any sesentive information here.

 

It makes it easier to give you a solution.

  1. Sample (dummy dataset) data as text, use the table tool in the editing bar
  2. Expected output from sample data
  3. Explanation in words of how to get from 1. to 2.

 

Best Regards,
Community Support Team _ Zeon Zheng

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

thrillhouse
Helper I
Helper I

Thanks, Theo.  I tried this as well, however, this also only display "0-2" as the only values even though that is not the case.  This column doesn't display the correct values when in a table either.  The IF statement I pasted above shows the correct values in a table, but doesn't seem to work as a legend.

@thrillhouse then it's related to the measure that you referenced.  Use the following measure and it will fix the issue:

 

Measure =

VAR _1 = COUNTROWS ( 'Table' )
RETURN
SWITCH (
     TRUE () ,
          _1 < 3 , "0-2" ,
          _1 < 5 , "2-4" ,
          "5+" )

Hope this helps.

Theo

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

TheoC
Super User
Super User

Hi @thrillhouse 

 

Can you create a calculated column as follows:

 

Column =

SWITCH (
     TRUE () ,
          [Main Categories Count] < 3 , "0-2" ,
          [Main Categories Count] < 5 , "2-4" ,
          "5+" )

Hope this helps.

Theo

 

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

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.