Imagine you have a field in your data called status, which gives the status of each order. The possible values for status are:
Paid Shipped Returned
While Exploring your data, you might want to have a separate background color for each status. This can be done using liquid html in the html: parameter of a dimension. This would look something like:
Hey Alison! Formatting of this type has been supported since we added liquid html formatting (prior to version 3.0). In this case, you’ll want to make sure you are using {{ rendered_value }}, rather than {{ linked_value }} or {{ value }}, in order to see the formatting. This should display the formatting in all relevant table cells (but not in visualizations).
Thanks lindsey and eFein. Question: is there already a feature request to make conditional formatting available as part of the “Table” visualization? I.e.: I would like to have the possibility that the end user can define color encoding in a table visualization, instead of me defining it upfront in LookML.
We have an open feature request for this and I have added you both to it!
At some point we will broaden table visualization options to end users who don’t know HTML or have access to the model. We know that customizing the table vis is an important feature and we want to build this correctly. We don’t have a solid near term plan for building this out yet, but it is something we’re aware about and want to improve.
To submit feature requests you can post a topic in Whats Next? Feature Requests category. You’ll also be added to our internal requests tool and we will update you on all progress!
As @mikhailxu mentioned, customization for table visualizations is an important feature that we want to make sure we build correctly. In the meantime, there are some existing patterns you can leverage to call attention specific rows based on conditions business users can define in table calculations in the Looker Explore UI.
I would say that not only is this an important feature to make available to end users, but also that given how frequently we need to make use of table functions in order to accommodate pivot-wise calculations that are not supported in the model, limiting conditional formatting to the model view significantly reduces its value.
Just ran into this issue again. I don’t see why a feature which is being applied to a SQL results set should be limited in any way whatsoever by the method in which said results set is generated.
Hey Ross - thanks for your feedback. We are planning to make conditional formatting available in the UI. It’s a feature we are hoping to address in the near/medium term.
Hey @MDiggity ! You’re really close here. Nil (or NULL) values are actually treated as false in Liquid, so you can just leave out the “not” and this should render. Give it a try and let me know how it goes!
Hey @maxcorbin , not sure I follow 100%. Can you help with the statement based on the one I used above? I want to show red if the value is NULL. I’m interpreting what you’re saying as:
{% elsif value %}
[make background red]
{% endif %}
Which would show background if value exists, not if value is NULL, right?
Hi @rufus thanks so much for the response! Unfortunately referencing {{ differentfield._value }} doesn’t seem to work for me.
I should note I’m applying these if statements to a measure that is an average, and the differentfield._value is a dimension I am pivoting on in the Look that I am creating. Would this change anything in the way these if statements compute?
Is there any chance any time soon of getting real (i.e. built into LookML) conditional formatting rather than this 3rd party, hack workaround of using liquid-html?