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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started


How can I show the legend and data labels together in a bar chart?

Earlier, when we had a requirement to bring legend and data labels together in a bar chart, we used to look for some custom visuals, but with Measure driven data labels  in the May 2023 update, we can achieve this in standard bar charts and line charts.
Here we are going to see how can we show the legend and data labels together in a stacked bar chart but in general

we can follow the same approach for other bar and line charts.




For the below example, we are going to use the sample data available in Power BI Desktop.


To achieve the requirement, first we need to drag and drop the required column to the visual fields pane, here the requirement is to show the sales values for countries split by product. I put all the required fields from the field list to fields pane.


Y-axis : Country

X-axis : Sales

Legend : Product



Now we need to write a measure like below to concatenate the legends and sales together in the data lables (It may vary depending on the requirement),






Sales Label = 
--Summing up the sales and format it to millions 
VAR _salesMillions =                           
    FORMAT ( SUM ( financials[ Sales] ), "#,,.0" ) & "M"
--concatenating product and sales for the current context
VAR _result = SELECTEDVALUE(financials[Product]) &"("& _salesMillions&")" 
RETURN _result







Next naviagate to the data labels option of the visuals and turn it on,




Under the values option we can see custom label,




And the turn on the custom label option, now we can see the option for add data will be enabled. 




Then you can add the measure that we have already created for the labels. 




If you don't see any labels, try to adjust (decrease/increase) the font size of the data labels and also turn on the overflow text option.

And to see the Totals we can turn on total labels.




Now can see the legends and data labels togehter in the visual.



Hope this article will be helpful. Please let me know your comments and suggestions.




Keep posting new blogs @Arul