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

formula to create percentage in pie chart?

Hello everyone!

 

I really, really need help with a formula to create percentages in a pie chart.

 

1. I have a SharePoint list.

 

image.png

 

2. This SharePoint list had been used into gallery ( GalleryEdit1 ) where I filtered based on the specific user ( User().email ).

 

marsyazahid72_0-1616285047631.png

 

3. I really, really need to create a pie chart in Power Apps that can calculate the percentage of each column in pie chart as below image (which I draw by myself for the expected result) where the percentage can be increased/decreased if any changes in the gallery.

 

marsyazahid72_1-1616286238923.png

4. The calculation that I can figure out is this

each column : FPoints of SRC / total FPoints *100%
total FPoints : 
(FPoints of SRC + FPoints of Clubs/Society + FPoints of Special Events + FPoints of Ad-Hoc Teams)

 

Highly appreciated anyone's attention and guidance.🤗

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@marsyazahid72 

Consider the following:

Change your Items property of the Pie Chart to -

AddColumns(
    AddColumns(
        GroupBy(
            GalleryEdit_1.AllItems,
            "EC_PA_Cri1",
            "_recs"
        ),
        "_total", CountRows(GalleryEdit_1.AllItems),
        "_recTotal", CountRows(_recs)
    ),
    "_label", EC_PA_Cri1 & " : " & Text((_recTotal/_total)*100, "%0")
)

Set the Series on your PieChart to  _recTotal

Set the Labels on your PieChart to _label

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
marsyazahid72
Helper I
Helper I

I also had tried to use my friend's code where she gets the result as below image but when I apply to my case, unfortunately, it did not works😢.

The pie chart she had createdThe pie chart she had created

her code for the pie charther code for the pie chart

Anyone could help me?😢

RandyHayes
Super User
Super User

@marsyazahid72 

Consider the following:

Change your Items property of the Pie Chart to -

AddColumns(
    AddColumns(
        GroupBy(
            GalleryEdit_1.AllItems,
            "EC_PA_Cri1",
            "_recs"
        ),
        "_total", CountRows(GalleryEdit_1.AllItems),
        "_recTotal", CountRows(_recs)
    ),
    "_label", EC_PA_Cri1 & " : " & Text((_recTotal/_total)*100, "%0")
)

Set the Series on your PieChart to  _recTotal

Set the Labels on your PieChart to _label

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,778)