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 / Creating a pie chart w...
Power Apps
Unanswered

Creating a pie chart with Dataverse

(0) ShareShare
ReportReport
Posted on by 4

Hi,

I am new to PowerApps and trying to create a simple Canvas app but hit a wall. I am hoping if someone can help point me in the right direction.

 

app.jpgtable1.jpgtabvle2.jpg

 

As shown above, there are two Dataverse tables (Table1 and Table2). Table2 is a list of locations which is used as a lookup for the "Location" column in Table1.

I wanted to create a pie chart based on the number of times the list of locations are visited (ie, count the number of times a location appears in Table1).

 

I have tried many methods, including Calculated Column, Collections, CountIf, AddColumns, but have hit a wall at every turn. 

The latest code I have tried (I put this in the OnSelect for the "Update Chart" button):

 

ClearCollect(loclist,Table2S.Name);
Collect(loclist1,AddColumns(loclist,"LocationCount",CountIf(Table1S,Location=loclist));

 

My simple idea was to create a collection with two columns and then use this collection to populate the pie chart. The 2 columns in the collection is:

Column 1 -- list of locations (as per Table2)

Column 2 -- the number of times the location is visited (using countif on Table1).

 

The above codes doesn't work. Perhaps there is an easier solution to this?

 

Hope that the gurus here can help.

 

Thanks.

 

 

 

I have the same question (0)
  • Mira Ghaly Profile Picture
    11,415 Moderator on at

    @bhenggoh 

    I have tried to reproduce at my end

    1. I have created a Table called location Primary column Name is Location Name

    2. Visits Table where location is a lookup

     To be able to get the pie chart working I had to do a Join using Add Columns , then Group BY , Then Add Columns again to get the row counts

    AddColumns(GroupBy(ShowColumns(AddColumns(Visits,"LocationName",LookUp(Locations,'Location Name'=Visits[@Location].'Location Name').'Location Name'),"LocationName"),"LocationName","myGroup"),"count",CountRows(myGroup))

     

    Let me explain part by part the above Expression:

    No. 1 the Join: So We join the table visits with the table Locations and show the new Column in the Location Name

    ShowColumns(AddColumns(Visits,"LocationName",LookUp(Locations,'Location Name'=Visits[@Location].'Location Name').'Location Name'),"LocationName")

     No. 2 Add Grouping by Location and the location group name is myGrouping

    GroupBy(ShowColumns(AddColumns(Visits,"LocationName",LookUp(Locations,'Location Name'=Visits[@Location].'Location Name').'Location Name'),"LocationName"),"LocationName","myGroup")

    No. 3 Then add another column to count the grouping

    AddColumns(GroupBy(ShowColumns(AddColumns(Visits,"LocationName",LookUp(Locations,'Location Name'=Visits[@Location].'Location Name').'Location Name'),"LocationName"),"LocationName","myGroup"),"count",CountRows(myGroup))

     

    This yield the below collection as below:

    Mira_Ghaly_0-1660722857672.png

     

    Mira_Ghaly_1-1660722973312.png

    This is how my table looks:

    Mira_Ghaly_2-1660723167235.png

     

     

  • Mira Ghaly Profile Picture
    11,415 Moderator on at

    @bhenggoh Has the solution worker for you?

     

  • bhenggoh Profile Picture
    4 on at

    Hi Mira

     

    Thank you for your response. So sorry for the late reply. I was sick the last week. 

    I have created a new screen and two new tables (location and visits) 

    screen.jpglocation.jpgvisits.jpg

     

    I added your formulae into the Onselect for the button I created.

     

    formulae.jpg

     

    But I got many errors. Being new to PowerApps, I have no idea what all these errors meant. Maybe I have done something wrong.

     

    error3.jpgerror2.jpgerror1.jpg

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard