Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hello Power BI Community,
I'm currently working on a bar chart in Power BI and facing a unique challenge. I wish to display all the bars in my chart, but I only want to label the top three bars based on their value. Is there a way to customize the chart to show labels only for these specific bars?
I think that Power BI doesn’t have a direct setting for this exact requirement. However, I am open to creative solutions or workarounds. Here’s what I am trying to achieve:
I believe this might involve creating a custom measure using DAX, but I am not entirely sure how to structure this measure to conditionally display labels only for the top three bars. Any guidance on how to approach this, or alternative suggestions, would be greatly appreciated.
Thank you in advance for your help!
Best
Chris
Solved! Go to Solution.
This example uses a star schema (dimension and fact tables with a one-to-many relationship) and these measures:
Amount = SUM ( FactTable[Amount] )
Data Label Formatting =
VAR vSourceTable =
ADDCOLUMNS ( ALLSELECTED ( DimGroup[Group] ), "@Amount", [Amount] )
VAR vRank =
RANK ( DENSE, vSourceTable, ORDERBY ( [@Amount], DESC, DimGroup[Group] ) )
VAR vResult =
// if rank is greater than 3, set data label color to match the background so it's invisible
IF ( vRank > 3, "#FFFFFF" )
RETURN
vResult
Set conditional formatting for the data labels color using the Data Label Formatting measure:
Use DimGroup[Group] in a visual:
Proud to be a Super User!
This example uses a star schema (dimension and fact tables with a one-to-many relationship) and these measures:
Amount = SUM ( FactTable[Amount] )
Data Label Formatting =
VAR vSourceTable =
ADDCOLUMNS ( ALLSELECTED ( DimGroup[Group] ), "@Amount", [Amount] )
VAR vRank =
RANK ( DENSE, vSourceTable, ORDERBY ( [@Amount], DESC, DimGroup[Group] ) )
VAR vResult =
// if rank is greater than 3, set data label color to match the background so it's invisible
IF ( vRank > 3, "#FFFFFF" )
RETURN
vResult
Set conditional formatting for the data labels color using the Data Label Formatting measure:
Use DimGroup[Group] in a visual:
Proud to be a Super User!
User | Count |
---|---|
77 | |
77 | |
68 | |
67 | |
49 |
User | Count |
---|---|
108 | |
105 | |
93 | |
83 | |
64 |