Preserving drill fields when conditional formatting is applied

Knowledge Drop

Last tested: Jan 21, 2019
 

Tip: Use the <a></a> tag instead of your <p></p> or <div></div> tag

When applying conditional formatting to the cells of your visualization using the HTML tag, you may lose your drill field functionality if not careful. To solve this use the <a></a> tag:

dimension: status {

type: string

sql: ${TABLE}.status ;;

html:

{% if value == 'complete' %}

<a href="{{ link }}" style="color: white; background-color: lightgreen; font-size:100%; text-align:center">{{ rendered_value }}</a>

{% elsif value == 'cancelled' %}

<a href="{{ link }}" style="color: white; background-color: red; font-size:100%; text-align:center">{{ rendered_value }}</a>

{% elsif value == 'pending' %}

<a href="{{ link }}" style="color: white; background-color: orange; font-size:100%; text-align:center">{{ rendered_value }}</a>

{% endif %}

;;

drill_fields: [created_date]

In our code above, we have applied used the <a></a> tag to apply conditional formatting to our status dimension which allows us to preserve our drill fields.

For more information on preserving drill fields while using conditional formatting, check out this Community article.

There is also another approach in the html parameter doc:

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>;;

This content is subject to limited support.                

Version history
Last update:
‎04-05-2021 09:01 AM
Updated by: