cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mike564
New Member

Not able to correctly define colors in the bar chart

Hi!

I'm new to powerapps and I'm currently stucked on a task that should be pretty simple to solve.

 

I have a sharepoint list and I have a gallery that shows the results based on a dropdown through which the user can choose the option he/she is interested in. I also wanted to convey the data regarding the chosed option through a pie or bar chart with specific colours depending on the current status (Stop (red), Completed (Green), In Progress (Orange), On Hold (Yellow)). So basically, I need it to count the number of activities in each different status and present them in the chart (the legend would be the different status and in the graph the exact number would be presented for each differente colour). Below I present how the graph is right now. I don't know why I'm getting only 2 different colours. Below I present how the chart looks like now as well as the itemcolorset property.

 

ForAll('sharepoint_list';Switch(Estado;"On Hold";RGBA(240; 255; 0; 1);"Completed";RGBA(94;193;108;1);"Stop";RGBA(242; 38; 19; 1);"In Progress";RGBA(248; 148; 6; 1);Color.Black))

 

 

Thanks in advance!!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@mike564 

So the trick is to get the order of the Items and the ItemColorSet to be the same. 

So, in the following formulas, the Status is sorted and then colors are sorted in the same order.

Change Items property to the following:

AddColumns(
    SortByColumns(
        GroupBy(
            Filter('sharepoint_list'; 
                Dropdown1_1.SelectedText.Value = "All" || Company = Dropdown1_1.SelectedText.Value); 
            "Status"; 
            "Group"
        ); 
    "Status"
    );
    "Cont";CountRows(Group)
) 

 

Then set the ItemsColorSet property to the following:

ShowColumns(
    AddColumns(
        SortByColumns(
            Distinct(Filter('sharepoint_list'; Dropdown1_1.SelectedText.Value = "All" || Company = Dropdown1_1.SelectedText.Value); Status);
            "Result"
        );
        "Value"; 
            Switch(Result,
                "On Hold";RGBA(240; 255; 0; 1);
                "Completed";RGBA(94;193;108;1);
                "Stop";RGBA(242; 38; 19; 1);
                "In Progress";RGBA(248; 148; 6; 1);
                Color.Black
            )
    );
    "Value"
 )

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

4 REPLIES 4
RandyHayes
Super User III
Super User III

@mike564 

The ItemColorSet needs to match the number of columns in your chart that you have.  If you have 4 bars in your chart then the ItemColorSet needs to have 4 colors in it, in the order of the bar colors you want.

 

If that doesn't move you forward, then provide your Items property formula for your chart and let's see what we can put together.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Thanks for the reply!

The problem is that the number of bars vary depending on the option the user chose in the dropdown. Below I present the Items property of the bar chart. The size of the bars and the numbers presented on them are working fine with the condition. The problem is the colours. When I specify 4 colours through the RGBA code, they vary. When I tried to specify a condition depending on the status, the colours also vary (because sometimes there are not 4 bars).

 

 

If(Dropdown1_1.SelectedText.Value = "All" ; AddColumns(GroupBy('sharepoint_list'; "Status"; "Group"); "Cont";CountRows(Group)) ; AddColumns(GroupBy(Filter ('sharepoint_list'; Company = Dropdown1_1.SelectedText.Value); "Status"; "Group"); "Cont";CountRows(Group)))

@mike564 

So the trick is to get the order of the Items and the ItemColorSet to be the same. 

So, in the following formulas, the Status is sorted and then colors are sorted in the same order.

Change Items property to the following:

AddColumns(
    SortByColumns(
        GroupBy(
            Filter('sharepoint_list'; 
                Dropdown1_1.SelectedText.Value = "All" || Company = Dropdown1_1.SelectedText.Value); 
            "Status"; 
            "Group"
        ); 
    "Status"
    );
    "Cont";CountRows(Group)
) 

 

Then set the ItemsColorSet property to the following:

ShowColumns(
    AddColumns(
        SortByColumns(
            Distinct(Filter('sharepoint_list'; Dropdown1_1.SelectedText.Value = "All" || Company = Dropdown1_1.SelectedText.Value); Status);
            "Result"
        );
        "Value"; 
            Switch(Result,
                "On Hold";RGBA(240; 255; 0; 1);
                "Completed";RGBA(94;193;108;1);
                "Stop";RGBA(242; 38; 19; 1);
                "In Progress";RGBA(248; 148; 6; 1);
                Color.Black
            )
    );
    "Value"
 )

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Ok, that was a very interesting approach! It works perfectly!

Thanks a lot!!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (77,504)