
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, no errors on either but the bars are staying grey?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use option for color as "Measure as Expression"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Should work, May be try with first expression? Can you please share sample application?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
