Announcements
cancel
Showing results for
Did you mean:
Contributor

## I am using "Color by expression" but the graphics are gray

Hi,

I am using "Color by expression" but the graphics are gray

The Dimension:

=if((DRIVERTIME < 341),'LOW',

if((DRIVERTIME >= 341) And (DRIVERTIME < 361),'MEDIUM',

if((DRIVERTIME >= 361),'HIGH')))

The Measure:

=Count(TRIPS)

Color by expression:

=if((DRIVERTIME < 341),Green(),

if((DRIVERTIME >= 341) And (DRIVERTIME < 361),Yellow(),

if((DRIVERTIME >= 361),Red())))

THANKS!!

Labels (1)
• ### expression

1 Solution

Accepted Solutions

Because the color expression is calculating over multiple rows, you must do some sort of aggregation over DRIVERTIME. As you have it now in the IF(), DRIVERTIME will return null when there are multiple rows. Try using "Avg(DRIVERTIME)" in your color expression.

-Rob

http://qlikviewcookbook.com

7 Replies
Anonymous
Not applicable

I would suggest finding the RGB value of the colour and using that e.g.

if("Gender"='Male',rgb(68,119,170),if("Gender"='Female',rgb(204,102,119), rgb(253,219,102)))

Contributor
Author

Bella, thanks

I also tried that option, but it does not work either

Rodrigo

Because the color expression is calculating over multiple rows, you must do some sort of aggregation over DRIVERTIME. As you have it now in the IF(), DRIVERTIME will return null when there are multiple rows. Try using "Avg(DRIVERTIME)" in your color expression.

-Rob

http://qlikviewcookbook.com

Partner - Contributor III

Please check if this might be the reason.

Are you using alternative dimension?

Contributor
Author

Eureka !!! That was the problem, thank you very much!!!

Partner - Contributor III

If you found the document clip useful, please mark my response as correct or appropriate.

Thank you

Partner - Creator

Please mark Rob Wunderlich's response as correct since you indicated that resolved your question.  I selected this question because it was still marked as unanswered - but upon reading it, you did get a correct response and it just needs to be marked.

Thank you.