Hi,
Is it possible to color code a PieChart in powerapps based on the values? The values are changing in the collection based on what item I am running it on and I was wondering if I could set the colors to these values instead of just assigning the colors in the order the values appear.
These are the values and the colors I want:
Covered = Green
Not Covered = Red
Preferred = LightGreen
Unknown = Gray
Any suggestions are welcome!
Thank you!
Solved! Go to Solution.
Yes, you can use the ItemColorSet property of the chart with an expression that defines the colors based on the items of the chart.
For your example, if the items is defined as a collection called 'datasource', and the name of the column based on which you want the color selection is called 'Name', you can use the following expression, using the ForAll and the Switch function, to define the colors:
ForAll( datasource, Switch( Name, "Covered", Color.Green, "Not Covered", Color.Red, "Preferred", Color.LightGreen, Color.Gray))
I do not see this is possible from below documentation:
https://powerapps.microsoft.com/en-us/tutorials/control-pie-chart/
@PAB wrote:Hi,
Is it possible to color code a PieChart in powerapps based on the values? The values are changing in the collection based on what item I am running it on and I was wondering if I could set the colors to these values instead of just assigning the colors in the order the values appear.
These are the values and the colors I want:
Covered = Green
Not Covered = Red
Preferred = LightGreen
Unknown = Gray
Any suggestions are welcome!
Thank you!
I just tested this in the color values of the chart and it works putting in a conditional statement to decide colors.
In my case I have a collection called "PurchasingData" and a status of completed, putting this code into the color of that pie chart works.
If(LookUp(PurchasingData,Status="Completed",Sum)>10,Magenta,Orange)
So to anwer your question yes, you could have it look to a value and change colors, edit: this might not work if the values are always changing in the pie chart but with some testing I think you could handle all of the values and decide colors.
Yes, you can use the ItemColorSet property of the chart with an expression that defines the colors based on the items of the chart.
For your example, if the items is defined as a collection called 'datasource', and the name of the column based on which you want the color selection is called 'Name', you can use the following expression, using the ForAll and the Switch function, to define the colors:
ForAll( datasource, Switch( Name, "Covered", Color.Green, "Not Covered", Color.Red, "Preferred", Color.LightGreen, Color.Gray))
Actually, rather than useing the "ForAll()" function, if you want to assign a specific color to a specific value in a column, then you can just provide the colors the order they appear in the collection. For instance I have a collection called "pieTasks" with the data shown below. I set "Items" of the Pie chart itself (not the "Composite Pie Chart") to "pieTasks" and the "ItemColorSet" to [Color.Yellow,Color.GreenYellow,Color.Red,Color.Blue,Color.DarkBlue] and that gives me Yellow for the first "Time Scope", which is 'Due Today", GreenYellow for the second "Time Scope", which is "New Today", Red for third "Time Scope" which is "Overdue', etc.
The resulting Pie Chart gives me the colors I want:
You'll find simply providing colours in order breaks down if you have a chart element of zero value, as the next element will have the colour value you assigned to this element.
@CarlosFigueira wrote:Yes, you can use the ItemColorSet property of the chart with an expression that defines the colors based on the items of the chart.
For your example, if the items is defined as a collection called 'datasource', and the name of the column based on which you want the color selection is called 'Name', you can use the following expression, using the ForAll and the Switch function, to define the colors:
ForAll( datasource, Switch( Name, "Covered", Color.Green, "Not Covered", Color.Red, "Preferred", Color.LightGreen, Color.Gray))
@CarlosFigueira Hello! This solution almost worked for me, what if i want the condition to be bigger than a number? Like if is bigger than 100, than Green, if is lower Red, and if is equal Yellow., for example.
@PedroViviani wrote:
@CarlosFigueira wrote:Yes, you can use the ItemColorSet property of the chart with an expression that defines the colors based on the items of the chart.
For your example, if the items is defined as a collection called 'datasource', and the name of the column based on which you want the color selection is called 'Name', you can use the following expression, using the ForAll and the Switch function, to define the colors:
ForAll( datasource, Switch( Name, "Covered", Color.Green, "Not Covered", Color.Red, "Preferred", Color.LightGreen, Color.Gray))@CarlosFigueira Hello! This solution almost worked for me, what if i want the condition to be bigger than a number? Like if is bigger than 100, than Green, if is lower Red, and if is equal Yellow., for example.
Nevermind, i made it work, instead of "Switch", i used an "If" function: ForAll(datasource;If(Name>100;Color.Green;Name<100;Color.Red;Name=100;Color.Yellow))
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
203 | |
187 | |
81 | |
50 | |
37 |
User | Count |
---|---|
292 | |
244 | |
123 | |
74 | |
55 |