Question

Show default text in single value visualization when no records

  • 1 February 2018
  • 2 replies
  • 275 views

I have a single value visualization, it shows name of the project selected in filter. The filter is a required filter. When nothing is selected in filter, I would like to show some text like “Select a project to see dashboard” - how can this be achieved?


2 replies

Userlevel 3

Hi!



I believe this can be accomplished using the following html added to the “Project” dimension in your model



html: {% if view_name.field_name._is_filtered %}

<a>{{rendered_value}} </a>

{% else %}

<a>"Please filter by a specific project" </a>

{% endif %};;



view_name.field_name._is_filtered will return true when there is a value for project in the filter, and then we use the liquid “if” statement to return the project name selected. Otherwise it will return False and we display the text “Please filter by a specific project”.



Note you will probably want to create a specific dimension purely for this purpose, so create a replica of the project dimension, and add the above html, then use this new project dimension in this dashboard, you will probably also want to make use of hidden: yes to hide this special field from the Explore page.



Best,


Andy

Thanks Andy for excellent tip.



I did add this into a dimension and it works in explore. However, in the dashboard, as the filter is required filter, the dashboard does not run before something is selected, so I still see a “-” instead of the text.



When, I tried removing the required filter flag, then the text does show up, but all the other tiles also start showing combined data for all projects. That, I want to avoid.

Reply