Question

Using HTML and Link parameters at the same time


I have some measures/dimensions where I’m trying to utilize both the HTML parameter and the Link parameter in the LookML. But whenever I add in HTML, the Link no longer works. Is this a known issue and is there any way around it?


6 replies

Userlevel 7
Badge +1

The secret here is to use {{ linked_value }} in your html parameter instead of just {{ value }}. That preserves the link and the html!

Hey 👋

Old thread but thought i’d chime in and let you know how I got around having to use {{ linked_value }} - As this wasn’t working for me either.

 

Instead I used the <a> tag for HTML to embed the hyperlink coming from the Link parameter. See below

 

    html:  {% if value < 1 %}

<div><a href="#drillmenu" target="_self">

The value is less than 1

</a></div>

{% else %}

<div><a href="#drillmenu" target="_self">

The value is not less than 1

</a></div>

{% endif %};;

 

I think my situation is a little weird because I’m not using {{ value }} anywhere in the HTML, so I can’t replace it with {{ linked_value }}. The measure I’m using is an aggregation of multiple entries, using PostgreSQL string_agg. And I’m using HTML to split each entry onto a new line. This method works, but if I add a link parameter, the link does not work. I assume there’s probably a better way to do this though.


measure: field_list {
type: string
sql: string_agg(distinct ${TABLE}.field, ',');;
html:
{% assign field_array = field_list | split:"," %}
{% for i in field_array %}
{{ i }}
<br>
{% endfor %} ;;

I’ve also tried bypassing the HTML by using the PostgreSQL new line character as the delimiter like this:

sql: string_agg(distinct ${TABLE}.field, E'\n');;


And that works in sql, but does not display correctly in Looker. Instead of a new line, it shows a space between each entry.

This page about Liquid Variables says that you can get “unexpected results” when using liquid with an aggregate measure. That’s exactly what I’m trying to do, so that explains why it’s not working.

Userlevel 7
Badge +1

Ahh got it. I don’t think there’s a way to preserve the link unless you’re using linked_value, which I guess wouldn’t be possible in your case. I can’t think of a way to get it to work, unless you manually added the link to the html block— You could add an icon with an img tag and have an href anchor to the link in question…


Anyone have a better way?

Userlevel 1

The secret here is to use {{ linked_value }} in your html parameter instead of just {{ value }}. That preserves the link and the html!

Hi, I know this is an old thread but how do that ? can you give me a syntax example for this?

Reply