cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Pie chart showing duplicates

Good Morning Community,

I have been working on a pie chart in my app that is being used as a time keeper for company projects, and it is quickly becoming the bane of my existence. I have a drop down that when you select a person's name, it pulls up a pie chart with all of the projects they have worked on and the time spent on each. I have tried several approaches - one with an SP list -

Filter('SP list name', Name = Dropdown1.Selected.Name) which displays every entry for the person selected - I know I probably have to use a GroupBy - which I tried with a collection - ClearCollect(projectCollection, 'SP list name'). I have tried multiple forms of group by, filter, distinct and have hit a road block. Any push in any direction is greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@Anonymous 

You are thinking about this correctly.  The pie chart will show each record in a collection as an individual slice.  Therefore you will need to group the time by project.

 

I imagine your Collection looks something like this.  Although it won't be exactly the same the important thing is two have at least two columns: Project and Hours.

\\Create a collection
ClearCollect(myTimeEntries,
{Date: Date(2020,1,1), Project: "ProjectA", Hours: 6},
{Date: Date(2020,1,1), Project: "ProjectB", Hours: 2},
{Date: Date(2020,1,2), Project: "ProjectA", Hours: 8},
{Date: Date(2020,1,3), Project: "ProjectB", Hours: 3},
{Date: Date(2020,1,3), Project: "ProjectC", Hours: 5},
{Date: Date(2020,1,4), Project: "ProjectC", Hours: 8}
);

 

Then you can group by project using this code below.

\\Group by and sum column code
ClearCollect(
    myGroupedEntries,
    GroupBy(TimeEntries,"Project","GroupedItems")
);

ClearCollect(
    myChartCollection,
    DropColumns(
        AddColumns(myGroupedEntries,"Sum of Jou",Sum(GroupedItems,Value)),
        "GroupedItems")
);

 

The resulting Collection called myChartCollection would look like this.  You could use myChartCollection as the data for your pie chart.

 

Project Hours
Project A 14
Project B 5
Project C 13

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

3 REPLIES 3
mdevaney
Super User
Super User

@Anonymous 

You are thinking about this correctly.  The pie chart will show each record in a collection as an individual slice.  Therefore you will need to group the time by project.

 

I imagine your Collection looks something like this.  Although it won't be exactly the same the important thing is two have at least two columns: Project and Hours.

\\Create a collection
ClearCollect(myTimeEntries,
{Date: Date(2020,1,1), Project: "ProjectA", Hours: 6},
{Date: Date(2020,1,1), Project: "ProjectB", Hours: 2},
{Date: Date(2020,1,2), Project: "ProjectA", Hours: 8},
{Date: Date(2020,1,3), Project: "ProjectB", Hours: 3},
{Date: Date(2020,1,3), Project: "ProjectC", Hours: 5},
{Date: Date(2020,1,4), Project: "ProjectC", Hours: 8}
);

 

Then you can group by project using this code below.

\\Group by and sum column code
ClearCollect(
    myGroupedEntries,
    GroupBy(TimeEntries,"Project","GroupedItems")
);

ClearCollect(
    myChartCollection,
    DropColumns(
        AddColumns(myGroupedEntries,"Sum of Jou",Sum(GroupedItems,Value)),
        "GroupedItems")
);

 

The resulting Collection called myChartCollection would look like this.  You could use myChartCollection as the data for your pie chart.

 

Project Hours
Project A 14
Project B 5
Project C 13

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Anonymous
Not applicable

Super Awesome - it grouped them how I needed them grouped - before I accept as solution - could you point in the direction of filtering based on an employee drop down (Dropdown1 - I didn't rename it) I'm sure I would just add it to one of the collections (I'm guessing the collection that sums the hours spent on a project

Anonymous
Not applicable

Nevermind figured it out - thank you so much - will accept as solution

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,452)