Question

Preserving Drill Fields When Formatting a Measure

  • 16 March 2015
  • 2 replies
  • 220 views

Userlevel 4
Badge

In Looker we can use the html: parameter to style output values. If not careful, then the drill functionality for measures could be overridden. The tag is an example of where this could happen.


Using the following will not work:


<font color="red">{{ linked_value }}</font>

linked_value renders an <a> tag, which is specifically styled. So adding a parent element with a different color won’t work. You can use link instead and render the <a> tag yourself with custom styling.


Like this:


<a href="{{ link }}" style="color: red;">Some extra text if I want it, {{ value }}</a>

Or like this if you want text that’s not clickable as well:


<span style="color: red;">
Some text that's red but not clickable,
<a href="{{ link }}" style="color: red;">Some red text that's clickable, {{ value }}</a>
</span>

Note: It is not recommended to use the <font> tag


2 replies

Userlevel 2

If you are using a <p

style format to get a background color for example and want to allow drilling into the measure to work, you can follow a structure like this:
html: {% if value < 15 %}
<p style="color: black; background-color: tomato; border-radius: 100px; font-size:120%; text-align:center"> <a href: {{linked_value}} </a> </p>
{% else %}
<p style="color: black; background-color: lightgreen; border-radius: 100px; font-size:120%; text-align:center"> <a href: {{linked_value}} </a> </p>
{% endif %}
;;

and get an output like this:


I have a drill look which takes you to another dashboard and I’d like to apply the html method to color code my single_value tiles. How can I mix both my drill look and html? here’s an example:


measure: diff_perc_drill_field {

type: average

sql: ${TABLE}.diff_perc ;;

value_format: “0.0%”

link: {

label: “Drill Look”

url:“https://…/…/…?Business_Unit={{_filters[‘business_unit’]|url_encode}}&Platform={{_filters[‘platform’]|url_encode}}&Metric_Name={{_filters[‘metric_name’]|url_encode}}”

}

}

Reply