cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cosmin89
Frequent Visitor

bar chart from sharepoint list

Hi everyone,

 

I'm trying to build a bar chart in PowerApps but i can't seem to get it right. I'll explain below:

I have a sharepoint list with two columns:

Departments        Category

HR                        Example1

IT                          Example 2

Logistics               Example 3

....                          ....

HR                        Example2

HR                        Example3

IT                          Example1

...                           ....

 

I want to display in the chart how many entries for each category does each departments has. Ex: Example1 : HR 36 entries

 

Can someone share some tips, ideas? Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @cosmin89 :

I suggest you use the processed data as the items property of the bar chart.I'v made a test for your reference:

1\My data source-MYList

ClearCollect(
 MYList,
 {Departments:"HR",Category:"Example1"},
 {Departments:"IT",Category:"Example2"},
 {Departments:"Logistics",Category:"Example3"},
 {Departments:"HR",Category:"Example2"},
 {Departments:"IT",Category:"Example3"}
)

 2\Set the Chart's items property to:

ShowColumns(
    AddColumns(
        GroupBy(
            AddColumns(
                MYList,
                "Category:Departments",
                Category & ":" & Departments
            ), /*create a new column "Category:Departments"*/
            "Category:Departments",
            "Group"
        ),/*group by "Category:Departments"*/
        "Numbers",
        CountRows(Group)
    ),/*create a new column "Numbers" and calculate the number of records in each category*/
    "Category:Departments",
    "Numbers"
)

1.JPG

Best Regards,

Bof

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @cosmin89 :

I suggest you use the processed data as the items property of the bar chart.I'v made a test for your reference:

1\My data source-MYList

ClearCollect(
 MYList,
 {Departments:"HR",Category:"Example1"},
 {Departments:"IT",Category:"Example2"},
 {Departments:"Logistics",Category:"Example3"},
 {Departments:"HR",Category:"Example2"},
 {Departments:"IT",Category:"Example3"}
)

 2\Set the Chart's items property to:

ShowColumns(
    AddColumns(
        GroupBy(
            AddColumns(
                MYList,
                "Category:Departments",
                Category & ":" & Departments
            ), /*create a new column "Category:Departments"*/
            "Category:Departments",
            "Group"
        ),/*group by "Category:Departments"*/
        "Numbers",
        CountRows(Group)
    ),/*create a new column "Numbers" and calculate the number of records in each category*/
    "Category:Departments",
    "Numbers"
)

1.JPG

Best Regards,

Bof

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,519)