web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Show the number of ite...
Power Apps
Answered

Show the number of items of a column inside an Excel spreadsheet in pie chart

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

so I have two groups: "Group1" and "Group2". I want to add a pie chart which would then show the number of elements for each group.

For example when I have 5 elements in total, 3 are from "Group1" and 2 are from "Group2", first of all, it would display the labels as "Group1","Group1","Group1","Group2","Group2" and the pie chart would also look similar.

I want the labels to be only the two groups, so "Group1", "Group2". And for the pie chart I would like to display only two parts with the respective number above each part.

 

I tried something with the function AddColumns(), but I didn't get what I am looking for.


Is there a way to accomplish this?

Best regards,

Softic Kabir

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Change the Items property of your PieChart to the following:

     

    AddColumns(
     GroupBy(yourDataSource,
     "yourGroupColumnName", "_recs"
     ),
     "_count", CountRows(_recs)
    )

     

    Your PieChart will now be provided with a grouped table of distinct group names and each will have a _count property which will have the count of the records that match that name.

    Set your pie chart Labels to "yourGroupColumnName" and the Series to _count.

    Obviously, replace the names of all the above columns and datasource to match what you have in your app.

     

    I hope this is helpful for you.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes

    I tried that, and the parts of the pie chart are of the correct size, but the part-label is still the "Group1" and "Group2". I want to show the number there, because for the "Labels" there is already "Group1" and "Group2".

    Best regards,

    Softic Kabir

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    I'm not really following what you mean by -"for the "Labels" there is already "Group1" and "Group2""

    Can you perhaps provide a screenshot of what you are seeing and any particular formulas?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    screenshot.png

    The labels of each part inside the pie chart, I want it to display the number and not the name again.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    So the part outside of the chart is the legend.  That is a separate control.

    The easiest thing to do to get what you want is to alter the label column of the chart.

    AddColumns(
     AddColumns(
     GroupBy(yourDataSource,
     "yourGroupColumnName", "_recs"
     ),
     "_count", CountRows(_recs)
     ),
     "_pieLabel", yourGroupColumnName & " (" & _count & ")"
    )

    Then set the Labels in the pie chart to _pieLabel

     

    This will give you labels with counts. 

     

    NOW, if you want to actually have a legend with just names and labels in the pie with just numbers, that is a bit more complex and requires a few more steps.

    SO, before jumping into that, will the above suffice for what you need?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at


    AddColumns(
     GroupBy(Table1.Gruppe;
     "Gruppe"; "_recs"
     );
     "_count"; CountRows(_recs)
    ;
     "_pieLabel"; "Gruppe" & " (" & _count & ")"
    )

    I changed it to this, but in the second last line, it shows an error for _count

    And when I enclose it with "", it doesn't show the number, but rather "Group(_count)"..

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    That is not the formula I provided.

    Please use the provided formula (I see your language needs semi-colons, so I have adjusted the below for you):

    AddColumns(
     AddColumns(
     GroupBy(Table1.Gruppe;
     "Gruppe"; "_recs"
     );
     "_count"; CountRows(_recs)
     );
     "_pieLabel"; Gruppe & " (" & _count & ")"
    )

    I've also added your column names and datasource, so the above should be a copy and paste to your Items property of the PieChart.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ah yes I see! It works now, many thanks! 🙂

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Excellent! Does that work well for you then?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    It does. I accepted that as solution 🙂

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 396 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 323

#3
WarrenBelz Profile Picture

WarrenBelz 193 Most Valuable Professional

Last 30 days Overall leaderboard