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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to add a Pie Chart?
Power Apps
Unanswered

How to add a Pie Chart?

(0) ShareShare
ReportReport
Posted on by 151

Easy visualization is important and I like to use pie charts that shows how products have been evaluated. But I need help, I can't find the documentation I need to understand how it works in Powerapps. Could you please help me of perhaps link to great guides?

 

My case:

In my app products are evaluated with sliders.

The sliders goes from 0 to 3 but I only show the values of 1-3. (0 = "No opinion" and 3 = Excellent)

 

How can I add pie charts that automaticly updates and shows how customer evaluates each product? 

 

Best regards

Ola

PieChart.png

 

 

 

 

Categories:
I have the same question (0)
  • carlosag Profile Picture
    on at

    The Pie Chart control requires you to provide data that already calculates the numbers you would like to plot. In this case you would need to do a "group by" Product and perform the calculations on them and then provide that to the Pie Chart.

     

    Here is an example on how you could add all the evaluations by product. Note that in this case I'm "hard-coding" a collection that attempts to match the schema you showed in your screenshot called "YourData" but really the only important line is the one creating the "ChartData" below.

    ClearCollect(YourData, 
     {CustomerName: "Al", Product: "Hat", Evaluation: 1},
     {CustomerName: "Brad", Product: "Hat", Evaluation: 3},
     {CustomerName: "Carly", Product: "Jacket", Evaluation: 2},
     {CustomerName: "David", Product: "Shoes", Evaluation: 2},
     {CustomerName: "Edward", Product: "Hat", Evaluation: 2},
     {CustomerName: "Frederic", Product: "Hat", Evaluation: 1}
    );
    ClearCollect(ChartData, AddColumns(GroupBy(YourData, "Product", "CustomerName"), "Total", Sum(CustomerName, Evaluation)))

     

    The only important line is where it GroupBy "Product" and then does a "Sum" of all the evaluations of the customers that rated that Product. You can then bind this to your Chart Items property and should work.

     

    If instead you wanted the average evaluation for each product you can just switch to use the Average function,

     

    ClearCollect(ChartData, AddColumns(GroupBy(YourData, "Product", "CustomerName"), "Total", Average(CustomerName, Evaluation)))

     

    Or if you wanted to render the "count of customers" that rated each product, use CountRows:

     

    ClearCollect(ChartData, AddColumns(GroupBy(YourData, "Product", "CustomerName"), "Total", CountRows(CustomerName)))

     

    Hope this helps. To repro this, just copy the formula on the OnVisible of the first screen (you might need to add a new screen and navigate to it on the designer and come back so that the OnVisible is triggered to see the results), optionally you could add it to a "OnSelect" of a button that you can easily trigger.

     

    Here is the average pie chart:

    PieChart.jpg

  • OlaH Profile Picture
    151 on at

    Thank you so much @carlosag. Now I'm beginning to understand this. But how do I do if I want a pie chart for just "Hat"?

    Look at my picture with the table and the pie chart. There are four evaluations of "Hat".

    Two of them says "1" (blue in the pie chart) and then one each for "2" (green) and "3" (purple).

    Acually, I don't care about the customername in this case. 

     

     

  • Verified answer
    carlosag Profile Picture
    on at

    You can add a "Filter" expression, and then group by the evaluation instead and you can count the number of customers that rated them that way.

    Here is how I would do it:

     

     

    	ClearCollect(YourData, 
    	  {CustomerName: "Al", Product: "Hat", Evaluation: 1},	  {CustomerName: "Brad", Product: "Hat", Evaluation: 3},	  {CustomerName: "Carly", Product: "Jacket", Evaluation: 2},	  {CustomerName: "David", Product: "Shoes", Evaluation: 2},	  {CustomerName: "Edward", Product: "Hat", Evaluation: 2},	  {CustomerName: "Frederic", Product: "Hat", Evaluation: 1}
    	);
    ClearCollect(ChartData, Sort(AddColumns(GroupBy(Filter(YourData, Product = "Hat"), "Evaluation", "CustomerName"), "Total", CountRows(CustomerName)), Evaluation))

     

     Note that you could even add a DropDown for users to select which product, for example:

     

    You can find an attached MSAPP that shows you how to do that.SampleApp.jpg

     

     

    https://www.carlosag.net/downloads/ProductsApp.msapp

     

     

     

  • OlaH Profile Picture
    151 on at

    I love to learn!

    Thank U @carlosag 4 helping me!

     

    Ola

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard