cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Help Creating Pie Chart

After some digging around, I figured out that the correct code needed to create a simple pie chart is:

 

AddColumns(GroupBy(Filter('CDS_Table',Email=User().Email), "Category", "Group"), "PrimaryID", Sum(Group, PrimaryId))

 

This creates a pie chart split by categories as expected (I only have 3 different ones at the moment):

 

pie.PNG

However, I noticed a problem. The above pie chart has the following data under 6 different records: Category1, Category1, Category2, Category2, Category3, Category3. The results should be a pie chart split perfectly in thirds. Category3 (the lightest green), however, seems to be larger than the other slices. I realised this is because rather than splitting the chart by category and each slice being a total of how many times that specific category shows up in the database, the pie chart is actually splitting the chart by category and then each slice is a total of the PrimaryID. Since each record in the table/entity was entered one after another, the difference between each PrimaryID is pretty tiny, but as you can tell by the largest slice, it does impact the results.

 

How can I change the code so that instead of totalling PrimaryID, each slice just counts how many times a certain Category shows up for each record in the table/entity? I've tried everything so far and for some reason it always seems to give me an error or unexpected results.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Helper II
Helper II

Scratch that... Think I fixed it:

 

AddColumns(GroupBy(Filter('CDS_Table',Email=User().Email), "Category", "Group"), "Category2", Sum(Group, CountA('CDS_Table'.Category)))

 

Just had my syntax all over the place before.

View solution in original post

2 REPLIES 2
Helper II
Helper II

Scratch that... Think I fixed it:

 

AddColumns(GroupBy(Filter('CDS_Table',Email=User().Email), "Category", "Group"), "Category2", Sum(Group, CountA('CDS_Table'.Category)))

 

Just had my syntax all over the place before.

View solution in original post

Hi @Tezz233,

 

Thanks for the update.

 

If you have any further quesitons ,please feel free to post back.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (71,150)