web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How can I display valu...
Power Apps
Answered

How can I display values of series and labels in pie chart for canvas app

(0) ShareShare
ReportReport
Posted on by 8

Hey, currently I'm using the following formular:

 

ForAll(
Filter(Choices(Inventarliste.Status);Value="In Verwendung" Or Value="Verfügbar") As A;
{
Number:CountIf(
ForAll(
Filter(Inventarliste;AssetType.Value = Dropdown1.Selected.Value);
ThisRecord.Status.Value) As B;
B.Value=A.Value);
Value:A.Value
}
)
 
to have this output:
 
invmgmt_lager.JPG
 
What do I have to edit/add in the formular to make the pie chart look like this PowerBI chart?


invmgmt_lager_powerbi.JPG
 
I hope someone can help me to get this working. Thanks in advance! 
Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @aeroh,

     

    Very interesting case, thanks for sharing! With the steps below you should be able to meet that requirement. 😊

     

    (1) Change the Items property of the PieChart control

     

    With(
     {
     wRecords:
     ForAll(
     Filter(Choices(Inventarliste.Status);Value="In Verwendung" Or Value="Verfügbar") As A;
     {
     Number:CountIf(
     ForAll(
     Filter(Inventarliste;AssetType.Value = Dropdown1.Selected.Value);ThisRecord.Status.Value
     ) As B;
     B.Value = A.Value
     );
     Value: A.Value
     }
     )
     };
     //Add column for displaying percentage
     AddColumns(
     wRecords;
     "Percentage";
     $"{Number} ({Round(Number / Sum(wRecords;Number) *100;2)}%)"
     )
    )

     

    (2) Select the PieChart control, navigate to the right property panel and select 'advanced'. Set the Labels and Series properties to the following:

    LaurensM_0-1692202481222.png

     

    (3) Select the Legend control, once again navigate to the advanced section in the right property panel. Here you will have to change the Items property from PieChart1.SeriesLabels to the full code of your PieChart Items property (copy - paste the code of step 1). The Value dropdown will have to be set to the 'Value' column.

     

    (4) Optional yet recommended: Save the PieChart Items code to a collection e.g. in the OnVisible of the screen. This way you can avoid copy-pasting the complex code (and Power Apps executing the code twice). Afterwards, set both the PieChart and Legend items properties to that collection.

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • aeroh Profile Picture
    8 on at

    Thank you for your answer! I tried your solution but I'm getting the Error "Expressions displayed in an interpolated string must evaluate to a text value or compatible type." on this line: 

    $"{Number} ({Round(Number / Sum(wRecords,Number) *100,2)}%)"

    And when I just comment out these lines 

    AddColumns( wRecords, "Percentage", $"{Number} ({Round(Number / Sum(wRecords,Number) *100,2)}%)" )

    the whole formular doesn't work anymore. 

     

    Do you maybe know why I get this error?

  • LaurensM Profile Picture
    12,516 Moderator on at

    @aeroh my apologies - I clearly mixed the US and EU Power Fx syntax. Please use the following code instead:

     

    With(
     {
     wRecords:
     ForAll(
     Filter(Choices(Inventarliste.Status);Value="In Verwendung" Or Value="Verfügbar") As A;
     {
     Number:CountIf(
     ForAll(
     Filter(Inventarliste;AssetType.Value = Dropdown1.Selected.Value);ThisRecord.Status.Value
     ) As B;
     B.Value = A.Value
     );
     Value: A.Value
     }
     )
     };
     //Add column for displaying percentage
     AddColumns(
     wRecords;
     "Percentage";
     $"{Number} ({Round(Number / Sum(wRecords;Number) *100;2)}%)"
     )
    )
  • LaurensM Profile Picture
    12,516 Moderator on at

    @aeroh as a note: I also adjusted my first comment since that contains the complete guide.

  • aeroh Profile Picture
    8 on at

    @LaurensM Thank you really much it's working now! I just have one last Question, is it somehow  possible to show the label of the smaller part in the chart as well? Currently it looks like this:

     

    invmgmt_lager_labels.JPG

    And only shows both labels when the small part is above a specific number. The ShowLabels Option is set to true and the Labels Position is set to Outside.

    Thanks in adavance for your help! 

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @aeroh,

     

    Labels indeed will not display when they only occupy a small percentage of the pie chart. Unfortunately, I am not aware of a workaround for this.

     

    Do note that the label will display on hover and when selected.

     

    I hope this helps!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard