Looker Community

Maintaining drill paths for custom HTML fields

We’ve all used the HTML parameter one way or another to format our LookML dimensions and measures, however what gets really annoying is that you lose drilling capabilities!

  measure: count {
    type: count
    drill_fields: [detail*]
    html:
  {% if value > 10000 %}
  <font color=“#42a338 ”>{{ rendered_value }}</font>
  {% elsif value > 5000 %}
  <font color=“#ffb92e ”>{{ rendered_value }}</font>
  {% else %}
  <font color=“#fa4444 ”>{{ rendered_value }}</font>
  {% endif %};;
  }

However there’s an easy solution! the #drillmenu link ! All you need to do add anchors linking to #drillmenu to your custom html!
Update: using {{fieldname._link}} also works and allows you to use the drilldown of another field !

  measure: count {
    type: count
    drill_fields: [detail*]
    html:
    <a href="#drillmenu" target="_self">
  {% if value > 10000 %}
  <font color=“#42a338 ”>{{ rendered_value }}</font>
  {% elsif value > 5000 %}
  <font color=“#ffb92e ”>{{ rendered_value }}</font>
  {% else %}
  <font color=“#fa4444 ”>{{ rendered_value }}</font>
  {% endif %}
    </a>;;
  }

Version with _link

  measure: count {
    type: count
    drill_fields: [detail*]
    html:
    <a href="{{count._link}}" target="_self">
  {% if value > 10000 %}
  <span style="color:#42a338;">{{rendered_value}}</span>
  {% elsif value > 5000 %}
   <span style="color:#ffb92e;">{{rendered_value}}</span>
  {% else %}
  <span style="color:#fa4444;">{{rendered_value}}</span>
  {% endif %}
    </a>;;
  }

5 Likes

This doesn’t works for my case. Can anyone help?

What about it doesn’t work?

Actually it worked, I had issue because of more than one logical statements and had to add the same code for drill on all the statements that made it work. But I wish if there was a better solution than that tho. Thanks for getting back!

1 Like

Hi , is there any way we can use the #drillmenu of a different field . i know i can use the link of a different field directly , but in that case , when clicked inside the single viz it directly goes to the url specified in the link . i want to display a drill menu of a another field .

the reason is my single value viz comprise of multiple measures rendered into one and i would like a drillmenu for each of the measure