Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
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.

 

 

 

  • bhenggoh Profile Picture
    4 on at
    Re: Creating a pie chart with Dataverse

    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

     

  • Mira Ghaly Profile Picture
    11,409 Super User 2025 Season 1 on at
    Re: Creating a pie chart with Dataverse

    @bhenggoh Has the solution worker for you?

     

  • Mira Ghaly Profile Picture
    11,409 Super User 2025 Season 1 on at
    Re: Creating a pie chart with Dataverse

    @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

     

     

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Microsoft Dataverse

#1
mmbr1606 Profile Picture

mmbr1606 22 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 19

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 15 Super User 2025 Season 1

Overall leaderboard

Featured topics