Skip to main content
Announcements
Applications are open for the 2024 Qlik Luminary Program. Apply by December 15 here.
cancel
Showing results for 
Search instead for 
Did you mean: 
fernandosanchez
Contributor II
Contributor II

How to change colors of specific bars in a bar chart / any chart...

Hello all,

I'm trying to manually change the color of my graphs but can't find a way to do it.

For example, I want to group this bar chart's bars' colors by Gate ( Gate 1, Gate 2... in the same color)

Labels (2)
9 Replies
Chanty4u
MVP
MVP

In colours tab u can give below expression

=if(DimensionField = 'Gate 1', red(), if(DimensionField = 'Gate 2', blue(), green()))

fernandosanchez
Contributor II
Contributor II
Author

But what if I created the dimensions 'Gate 1', 'Gate 2'... by grouping other variables in the graph's expression?

Chanty4u
MVP
MVP

 if you grouped the variables based on an expression like

if(Field = 'A', 'Gate 1', if(Field = 'B', 'Gate 2', 'Gate 3'))

where 'A', 'B', and 'C' represent the variables,

you can use the same expression in the "Colors" option. This will ensure that the colors assigned to 'Gate 1', 'Gate 2', and 'Gate 3' are consistent with the grouping.

fernandosanchez
Contributor II
Contributor II
Author

I have this expression for my graph:

=If([BuildPermitVW.BusinessUnit] = 'LATAM' and InProgress = 1 and WildMatch(BuildPermitVW.Gate,'1', '1a', '1b', '1c', '1d', '1e', '1f', '1g', '1h', '1i', '1j', '1k', '1l', '1m', '1n', BuildPermitVW.Gate)<=15,'Gate 1', If([BuildPermitVW.BusinessUnit] = 'LATAM' and InProgress = 1 and WildMatch(BuildPermitVW.Gate,'2', '2a', '2b', '2c', '2d', '2e', '2f', '2g', '2h', '2i', '2j', '2k',BuildPermitVW.Gate)<=12,'Gate 2', If(InProgress = 0, null(), If([BuildPermitVW.BusinessUnit] = 'LATAM' and InProgress = 1 and BuildPermitVW.Gate = 0,'Gate 0', if([BuildPermitVW.BusinessUnit] <> 'LATAM', null(), BuildPermitVW.Gate)))))

 

I pasted it in the Colors option and it doesn't work (all the colors become gray), I've tried to change the 'Gate 1' for green(), for example, but it won't work...

Chanty4u
MVP
MVP

=if([BuildPermitVW.BusinessUnit] = 'LATAM' and InProgress = 1,

    if(WildMatch(BuildPermitVW.Gate, '1*', '1a', '1b', '1c', '1d', '1e', '1f', '1g', '1h', '1i', '1j', '1k', '1l', '1m', '1n') <= 15,

        RGB(0, 128, 0), // Green color for Gate 1

        if(WildMatch(BuildPermitVW.Gate, '2*', '2a', '2b', '2c', '2d', '2e', '2f', '2g', '2h', '2i', '2j', '2k') <= 12,

            RGB(255, 0, 0), // Red color for Gate 2

            if(BuildPermitVW.Gate = 0,

                RGB(0, 0, 255), // Blue color for Gate 0

                RGB(192, 192, 192) // Gray color for other Gates

            )

        )

 

  )

)

 

 

Please check the closing brackets according to your expression 

fernandosanchez
Contributor II
Contributor II
Author

It just colors the Gate 0 in green 😞

Chanty4u
MVP
MVP

Try this 

if([BuildPermitVW.BusinessUnit] = 'LATAM' and InProgress = 1,

    if(WildMatch(BuildPermitVW.Gate, '1*', '1a', '1b', '1c', '1d', '1e', '1f', '1g', '1h', '1i', '1j', '1k', '1l', '1m', '1n') > 0 and WildMatch(BuildPermitVW.Gate, '1*', '1a', '1b', '1c', '1d', '1e', '1f', '1g', '1h', '1i', '1j', '1k', '1l', '1m', '1n') <= 15,

        RGB(0, 128, 0), // Green color for Gate 1

        if(WildMatch(BuildPermitVW.Gate, '2*', '2a', '2b', '2c', '2d', '2e', '2f', '2g', '2h', '2i', '2j', '2k') > 0 and WildMatch(BuildPermitVW.Gate, '2*', '2a', '2b', '2c', '2d', '2e', '2f', '2g', '2h', '2i', '2j', '2k') <= 12,

            RGB(255, 0, 0), // Red color for Gate 2

            if(BuildPermitVW.Gate = 0,

                RGB(0, 0, 255), // Blue color for Gate 0

                RGB(192, 192, 192) // Gray color for other Gates

            )

        )

 

  )

)

fernandosanchez
Contributor II
Contributor II
Author

Now it just colored the Gate 0 in blue 

Kushal_Chawda

@fernandosanchez  Barchart properties-> Appearance -> Colors and Legends -> Disable Auto -> Select "By Expression"  from custom drop down options and put below expression

=if(wildmatch(Status,'*Gate 0*',RGB(120,60,90),
if(wildmatch(Status,'*Gate 1*',RGB(120,110,90),
if(wildmatch(Status,'*Gate 2*',RGB(120,60,150))))

You can update the RGB colors of your choice and add additional condition for more status