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 / Strange behaviour with...
Power Apps
Answered

Strange behaviour with ItemColorSet on a barchart

(0) ShareShare
ReportReport
Posted on by 57

Hello

 

A user is having some strange behaviour when trying to change a bar charts column colours.

 

They have a SharePoint list with a single line of text column called "Status"

 

SharePoint records are loaded into a collection (Ive also tried pointing the chart directly to the SharePoint list) -

ClearCollect(Records,
 'SharePoint List'
);

The bar chart 'Items' is set to -

AddColumns(
 GroupBy(
 Records,
 "Status",
 "SubGrp"
 ),
 "Count",
 CountRows(SubGrp)
)

The bar chart ItemColorSet is set to -

ForAll(
 Records,
 Switch(
 Status,
 "complete",
 Color.Blue,
 "on track",
 Color.Green,
 "delayed",
 Color.Red,
 "Paused",
 Color.Purple,
 Color.Black
 )
)

But all the columns show as the colour blue, matching the "complete" records color. If i remove "complete" from the formula -

ForAll(
 Records,
 Switch(
 Status,
 "on track",
 Color.Green,
 "delayed",
 Color.Red,
 "Paused",
 Color.Purple,
 Color.Black
 )
)

All the columns are then black.

 

If i exclude any records that equal "complete" when populating the collection -

ClearCollect(
 List,
 Filter(
 'SharePoint List',
 Status <> "complete"
 )
);

Then all the remaining columns are coloured correctly as per the switch formula.

 

The only difference is theres 26 records that equal "complete" and only 1 of the other types but can't see why that would make a difference.

 

Any ideas?

 

Thanks

 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @StuPower 

    The order of the color records in the ItemColorSet must match and be in the same order and same number of records as the Items of the chart.

     

    This can also be done without a collection.

    Do the following steps:

    1) Add a new SCROLABLE screen to your app.  On that screen, select the Canvas control that is created on it.  Resize to be very small and then ctrl-X (cut) it from the screen.

    2) Delete the new screen you just added.

    3) Back on your other screen, paste the canvas you just cut from the other new screen.

    NOTE: you are creating what I call a dynamic variable.  You can keep it on a separate screen, but I like to have these in context of where they are used.

     

    Now, I will assume that the canvas is Canvas1 and the DataCard in it is DataCard1 if not substitute as needed.

    1) Go to DataCard1 and then choose the Update property. 

    2) In the Update property, but the following formula:

    {
     ChartItems:
     AddColumns(
     GroupBy('SharePoint List',
     "Status",
     "SubGrp"
     ),
     "Count", CountRows(SubGrp),
     "_color", 
     Switch(Status,
     "complete", Blue,
     "on track", Green,
     "delayed", Red,
     "Paused", Purple,
     Black
     )
     )
    }

     

    Now, in the Items property of your Chart : DataCard1.Update.ChartItems

    And in the ItemColorSet property : ForAll(DataCard1.Update.ChartItems, {Value: _color})

     

    You will now have a dynamic (will change as underlying list values change) chart with the proper colors.

     

    I hope this is helpful for you.

  • StuPower Profile Picture
    57 on at

    Brilliant thankyou for such a detailed reply!

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