Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
mmurray04
Contributor II
Contributor II

Bar Chart Color by expression

Hi,

Can you help with this expression, I was trying to color each bar (3 in total) by inspection status, Initial to be blue, passed to be green, failed to be red:

if([InspectionStatus]='Failed',rgb(242,0,0)),if([InspectionStatus]='Passed',rgb(0,242,0)),if([InspectionStatus]='Initial',rgb(0,0,242))

The above expression gives the error :   garbage after expression ','

The below expression colored all the stacked bars blue, but I need to get the three colors:

=if(InspectionStatus,'Initial',rgb(0,0,242))

Thanks in advance,

Newbie Qlik User Mike

1 Solution

Accepted Solutions
mmurray04
Contributor II
Contributor II
Author

With help from our BI team, we solved it by changing the measure expression to one instead of three, adding a bar inspection status dimension and the below color expression:

Count({$<Bucket ={'Requested Inspections'}>*$<InspectionType = {"*Hazard Elimination Assessment*"}>} distinct IMInspectionID)

if(InspectionStatus='Initial', blue(),
if(InspectionStatus='Passed', green(),
if(InspectionStatus='Failed', red())))

Thanks, Mike

View solution in original post

8 Replies
Anil_Babu_Samineni
MVP
MVP

Statement closing in the first condition it self, Try as follows

if([InspectionStatus]='Failed',rgb(242,0,0),if([InspectionStatus]='Passed',rgb(0,242,0),if([InspectionStatus]='Initial',rgb(0,0,242))))

Or

Pick(Match([InspectionStatus], 'Failed', 'Passed', 'Initial'), rgb(242,0,0), rgb(0,242,0),rgb(0,0,242))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
mmurray04
Contributor II
Contributor II
Author

Thanks, no errors on either but the bars are staying grey?

Anil_Babu_Samineni
MVP
MVP

Use option for color as "Measure as Expression"

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
mmurray04
Contributor II
Contributor II
Author

bar colors.png

Anil_Babu_Samineni
MVP
MVP

Should work, May be try with first expression? Can you please share sample application?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
mmurray04
Contributor II
Contributor II
Author

I tried this and still grey:

Pick(Match([InspectionStatus], 'Failed'), rgb(242,0,0))

i will check if i can share a sample, Thx, Mike

mmurray04
Contributor II
Contributor II
Author

Here are the measure expressions if it helps:

Count({$<Bucket ={'Requested Inspections'}>*$<InspectionStatus = {'Initial'}>*$<InspectionType = {"*Hazard Elimination Assessment*"}>}distinct IMInspectionID)

Count({$<Bucket ={'Requested Inspections'}>*$<InspectionStatus = {'Failed'}>*$<InspectionType = {"*Hazard Elimination Assessment*"}>}distinct IMInspectionID)

Count({$<Bucket ={'Requested Inspections'}>*$<InspectionStatus = {'Passed'}>*$<InspectionType = {"*Hazard Elimination Assessment*"}>}distinct IMInspectionID)

mmurray04
Contributor II
Contributor II
Author

With help from our BI team, we solved it by changing the measure expression to one instead of three, adding a bar inspection status dimension and the below color expression:

Count({$<Bucket ={'Requested Inspections'}>*$<InspectionType = {"*Hazard Elimination Assessment*"}>} distinct IMInspectionID)

if(InspectionStatus='Initial', blue(),
if(InspectionStatus='Passed', green(),
if(InspectionStatus='Failed', red())))

Thanks, Mike