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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
learner03
Post Partisan
Post Partisan

Text Measure as legend in Pie chart

I have a table, through which it calculates Month's cover of Stock. 

For this the user inputs the Number of Months as a variable  and I have used what if parameter for this. So, if user enters 3 , it calculates sum of last 3 months of sales and  divide current stock on hand by the sum of last 3 months sales  to give Number of month's cover.

Now I need to create Pie chart of  this depending on the Month's cover calculation. So if the answer is between 0-5 then pie chart slice is green, if month's cover is 6-10 then yellow and above that it should be red..

 

All my month's cover, sum of sales are measures. I can't get how to make a legend on pie chart based on 0-5,6-10 and greater that 10 for this.

 

7 REPLIES 7
asitm
Helper III
Helper III

@learner03  there are Paid custom visuals on Appsource that let you use measures as colours for Pie chart
Advanced Pie and Donut chart (Pie chart with full legend label)
https://appsource.microsoft.com/en-us/product/power-bi-visuals/piechartwithlegendlabelpro 


1. Add the measure you want to use in 'Color by' box. (1st screenshot)
2. Click on the yellow color tray icon (top left), and use Format Style > Rules (2nd screenshot below)

asitm_0-1697091315365.png

 

asitm_1-1697091333872.png

 

Nil
Frequent Visitor

Hi there,

Have you got the solution?

I am having the same issue

Thank you

Anonymous
Not applicable

Hi @learner03 ,

 

Here's a possible idea.

You can create a seperate table for the range.

vstephenmsft_0-1679302294330.png

Use the SWITCH function to judge the different results of fan'h.

Measure = SWITCH(MAX('Table (2)'[Legend]),"0-5",[Expression1],"6-10",[Expression2]))

vstephenmsft_1-1679302505589.png

                                                                                                                                                         

Best Regards,

Stephen Tao

 

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

@Anonymous I used this approach from one of the videos and could create the chart, but there is a table underneath it which has details about items associated with customers. I also have slicers to select customers. The working should be when I click on a particular slice of pie chart, the data should be filtered or other ay around,when I click on particular slicer filter for customer the pie chart should change. This link is not happening as I do not have common column to connect.

vicky_
Super User
Super User

I don't think you can use measures in the legend. But you can create a measure for each of the groups and add each measure to the Values section.

@vicky_ Can you provide me with an example please

You need to create a column by clicking the 3 dots next to your table, choose "New column". You will see a window appears like when you create a new meausre. Put in: newcolumn = tablename[meausername]

Choose your pie char, drag the newcolumn to Legend and Values. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.