Is there a way to display a custom message if a determined condition is met?

Hello, community! This is my first interaction here.

I’m facing some doubts in regard to conditional messages in Looker. I don’t really know if that’s a thing, but here’s the problem:

  • I have a “Most Recent Survey” string-type dimension that labels Yes or No if the current visualizations are based on the most recent survey answers.​​​​​​;
  • I also have a measure “Total Respondents” that outputs the total number of collaborators that answered the survey;
  • There are teams that did not answer the last survey and thus receive no data if they filter the charts by their squad name;

I’d like to know if there’s anyway I can create a filter that if total respondents < 1, than a message like “No responses have been submitted for this survey round” prompts instead of Looker’s default message.

If something in this question isn’t clear, please let me know.

Thanks in advance!

Solved Solved
0 3 1,123
1 ACCEPTED SOLUTION

I believe that in this case, the best alternative would be to use conditional formatting with liquid on the HTML parameter.

Something like this:

dimension: responses_formatted {
sql: ${TABLE}.responses ;;
html: {% if value < 1 %}
" No responses "
{% else %}
{{ value }}
{% endif %}
;;
}

View solution in original post

3 REPLIES 3

I believe that in this case, the best alternative would be to use conditional formatting with liquid on the HTML parameter.

Something like this:

dimension: responses_formatted {
sql: ${TABLE}.responses ;;
html: {% if value < 1 %}
" No responses "
{% else %}
{{ value }}
{% endif %}
;;
}

I believe that in this case, the best alternative would be to use conditional formatting with liquid on the HTML parameter.

Something like this:

dimension: responses_formatted {
sql: ${TABLE}.responses ;;
html: {% if value < 1 %}
" No responses "
{% else %}
{{ value }}
{% endif %}
;;
}

I have one doubt that I couldn’t understand through the docs. Is that ‘value’ word a constant in these liquid variables, or should I change it for one of my created variables?

Either way, thanks for the response!

Hey @beylouniluciano , in this case, ‘value’ is a variable, defined by the result from the SQL query. Son in this case if your SQL parameter is “responses” then value = responses.

If you add it to other dimensions or measures, the value will be the query on that specific dimension.

TLDR; you can use value every time and will select the value from the selected dimension or measure.

Top Labels in this Space