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

Coloring top N in a bar chart with legend or conditional formatting

Hi all!


I'm running into an issue that really stumps me. I want to differentiate the top 5 bars in a bar chart by giving them a different color and I keep running into a wall. It has to be done using a measure as the top 5's need to change when filtering.


I've been trying to write a measure with the TOPN dax function that can either be inserted as a legend or as a field value in conditional formatting, but I can't get the syntax right.


Not omitting an example due to laziness - I just had nothing worth posting ‌😅

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create a solution for your datamodel.

 

Jihwan_Kim_0-1673629815541.png

 

Jihwan_Kim_1-1673630476312.png

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

v-zhangti
Community Support
Community Support

Hi, @SleveMcDichael 

 

You can try the following methods.
Measure:

Rank = RANKX(ALL('Table'),CALCULATE(SUM('Table'[Value])),,DESC)

vzhangti_1-1673851242393.png

Color = IF([Rank]<=5,"Green")

vzhangti_2-1673851320522.png

Result:

vzhangti_3-1673851342379.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @SleveMcDichael 

 

You can try the following methods.
Measure:

Rank = RANKX(ALL('Table'),CALCULATE(SUM('Table'[Value])),,DESC)

vzhangti_1-1673851242393.png

Color = IF([Rank]<=5,"Green")

vzhangti_2-1673851320522.png

Result:

vzhangti_3-1673851342379.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below can provide some ideas on how to create a solution for your datamodel.

 

Jihwan_Kim_0-1673629815541.png

 

Jihwan_Kim_1-1673630476312.png

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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