cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sephiel
Helper II
Helper II

Pie chart colors by specific values? (Item property is nested calculation)

Hi all,

 

I've got hopefully a simple request, but layered in a few issues. I've got pie charts showing a percentage progress of files I get, which I mark "yes" when I get the files I need (it's a Yes/No column). So this is a simple true or false pie chart. Problem is, the colors can change depending on the status of the first record in my SharePoint list. This image below has it's ItemColorSet to where Red is first (because the first record is false) and the Green is true. I didn't realize that the order of colors is based on the value of the column in the first record. If I change it to true, the colors switch and are incorrect.

 

Capture2.PNG

 

So I saw through other posts that you can define the colors based on the result using ItemColorSet and the Switch function, but I must be doing something wrong, as it shows colors I haven't defined:

 

Capture3.PNG

 

Do I need to use a different column? AddColumn? Not sure, I'm stuck!

 

Thanks very much for the help Smiley Happy

5 REPLIES 5
v-sheyu-msft
Community Support
Community Support

HI @Sephiel,

Can you share a bit more about your issue?

Can you show me the error info about your issue?

Do you want to define the color based on the result?

 

I made a test . 

I created a sharepoint list named ‘test3.

10.PNG

 

11.PNG

Set items property of piechart1 to:

AddColumns(GroupBy(test3,"columnname","GroupData"),"percentagedatatotal",CountRows(GroupData)/CountRows(test3))

Set itemcolorset property of piechart1 to:

ForAll(test3,Switch(columnname,true,Color.Green,false,Color.Red,Color.Gray))

regards,

eason

Community Support Team _ Eason YU
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Eason! You are exactly right - I want to define the color by the results of the record in the column. It's a yes/no column so the only options are true and false.

 

So, your example at least got me a result, which was further than I was able to take it - however the colors it's showing are wrong...

 

See my attached image for the code! 

hi @Sephiel,

 

please try to recreate a Pie Chart and check if it is solved

 

regards,

eason

Community Support Team _ Eason YU
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Capture.PNG

 

Hi Eason, here is a new screen with a new pie chart applied - same code to group the records by true/false but with your ItemColorSet code. Still getting the light green/blue combo instead of red and green.

 

Now that I think back - the column in question is actually a calculated column based on an ISBLANK of a different column. But the result is set to yes/no, and the resulting colors are still the same.

 

Capture2.PNG

 

I also tried publishing the app and looking at the published results as I have heard sometimes that changes things. No changes for my app though.

 

Any insight greatly appreciated!

Also I tried changing the result of the first record of that column to "true" - the colors switched, which tells me that the ItemColorSet code seems to be bypassed to get this result, and it's defaulting to the colors displayed when there is a blank ItemColorSet.

 

Capture3.PNG

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.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

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 (3,446)