Can I set colors (or apply other custom formatting) in my bar chart based on a measure’s value?
Here is a simple example generated in Excel. There is a red reference line at 130. All the measure values greater than it are dark green and the bars below it are a lighter green.
I noticed that release 4.8 has conditional formatting for table visualizations, so perhaps it will be coming for other visualization types in the near future.
@gregono and @lchang No word yet on the timeline for being able to do conditional formatting on other kinds of visualization, but this is the direction we’re heading ��
Thanks for the feedback. I’ll let the product team know that you’d like to see conditional formatting options for bar chart visualizations in the future!
You could potentially use the pattern below, if you don’t have too many buckets.
Imagine I’m looking at user count per state and I want to break out states with 300+ users. Select the dimension & measure and run the query.
Now, create two (or more) table calculations:
if(${users.count} >= 300, ${users.count}, null)
and:
if(${users.count} < 300, ${users.count}, null)
Hide the original measure, and go into viz settings and stack them. This will remove the extra whitespace between the two table calc series. Add a trend line if you like.
Unfortunately the table calculation method makes drills unusable, some native way of doing this so that we don’t lose the drilling functionality would be ��
We could do what Brecht has suggested using measures instead of tablecalcs- then we can define drills in those measures.
We’ll want to create two measures with CASE WHENs in the sql parameter, like so:
measure: count_g_500 {
type: number
sql: CASE WHEN ${count} > 500 THEN ${count} ELSE NULL END;;
drill_fields:
}
```auto
measure: count_l_500 {
type: number
sql: CASE WHEN ${count} <= 500 THEN ${count} ELSE NULL END ;;
drill_fields:
}
Here’s an example of what this looks like in the explore:

This approach will preserve drilling into the vis!
Cheers,
Adina
```
What’s the update on time-based conditional formatting?
More advanced formatting options are coming with the final phase of the new table visualization that’s been rolling out in chunks as the beta table-next visualization option. I’m not sure if time-based formatting will be included, but row-by-row custom formatting will definitely be possible then so you’d be able to easily highlight today.
This is a good idea however I have always had issues with drilling into measures that use CASE WHEN. I usually have to revert to this:
[Discrepancy when drilling into measures](https://discourse.looker.com/t/discrepancy-when-drilling-into-measures/3464) Exploring
If a measure is being drilled into and outputting incorrect information, this could be due to a CASE WHEN statement in your measure. Let’s say we want a measure that counts how many companies have exactly 13 employees. We could create a measure that includes a CASE WHEN statement in the sql parameter. For example,
Can you confirm that drilling on this works because it is a number possible instead of an aggregation?
For Looker users who have active accounts, I think you can also upvote this by clicking the Help icon in the upper right corner of your Looker instance, then clicking on Product Idea?
There they seem to use Pendo to manage feature requests. The issue # is 17646. If this link doesn’t work, you can click on any issue and just replace the # in the URL: