Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Qhog
Contributor
Contributor

Color Expression

Hello,

I'm have a bar chart which I want to capture three categories from the data about People. 

In my source file the possible values in the People column are: "OK, Potential Issues, and Not Okay."

How can I create a bar chart in which data with each distinct text value has an assigned color? My attempts at using color by expression and the following code has failed.

If(People = 'Ok', green()

If(People='Potential Issues', yellow()

If(People='Not Okay', red())))

 

Labels (2)
1 Solution

Accepted Solutions
Rodj
Luminary Alumni
Luminary Alumni

I think perhaps that there's some confusion here regarding what should be configured with a colour.

From what I can tell the count of "People" is your measure however you also said that it has the three values you want to categorise the KPI by, so that would make it a dimension. If that is the case then you must be counting some other field, hence @StarinieriG  correctly suggested creating a master DIMENSION, not a master measure.

If you had a master dimension with your values of Ok, Potential Issues, or Not Okay, you could assign each value a colour. To assign a colour to a master measure you are in fact assigning a colour to a range of values that are the result of the measure, e.g. count(ID). So it sounds like a master measure is what you want but we can't be sure without more information from you.

What is the measure in the bar chart you mentioned? Your original attempt should almost work as a colour by expression, assuming you have a dimension of Date and a measure of Count(some_field), your colour expression could be:

If(People = 'Ok', green(),

    If(People='Potential Issues', yellow(),

        If(People='Not Okay', red()

)))

You appeared to be just missing the commas after the positive result in each if statement.

Using the master dimension with defined colours would definitely be best practice, particularly if you are going to reuse the dimension.

I hope that clarifies things a little.

Cheers,

Rod

View solution in original post

3 Replies
StarinieriG
Partner - Specialist
Partner - Specialist

Hi,

create a master dimension for that field and then use it. 

Inside master dimension settings you could set colors for each value.

Qhog
Contributor
Contributor
Author

Hello and thanks for the response,

 

I should point out that People is one of several KPIs that I want to track. All KPIs are assigned a status of either Ok, Potential Issues, or Not Okay.

The bar charts I am creating use the date as the dimension. 

From what you told me it appears as though I can set a Master Measure and then assign colors that way.

My question is:

Must I create a master measure(s) for each KPI and each color assignment? If so or otherwise, how exactly should my master measures be formatted?

 

Thanks

Rodj
Luminary Alumni
Luminary Alumni

I think perhaps that there's some confusion here regarding what should be configured with a colour.

From what I can tell the count of "People" is your measure however you also said that it has the three values you want to categorise the KPI by, so that would make it a dimension. If that is the case then you must be counting some other field, hence @StarinieriG  correctly suggested creating a master DIMENSION, not a master measure.

If you had a master dimension with your values of Ok, Potential Issues, or Not Okay, you could assign each value a colour. To assign a colour to a master measure you are in fact assigning a colour to a range of values that are the result of the measure, e.g. count(ID). So it sounds like a master measure is what you want but we can't be sure without more information from you.

What is the measure in the bar chart you mentioned? Your original attempt should almost work as a colour by expression, assuming you have a dimension of Date and a measure of Count(some_field), your colour expression could be:

If(People = 'Ok', green(),

    If(People='Potential Issues', yellow(),

        If(People='Not Okay', red()

)))

You appeared to be just missing the commas after the positive result in each if statement.

Using the master dimension with defined colours would definitely be best practice, particularly if you are going to reuse the dimension.

I hope that clarifies things a little.

Cheers,

Rod