Why am I seeing a Variable not found "value" error in liquid when checking if value == true?

Knowledge Drop

Last tested: May 14, 2020
 

The Problem

You're trying to check if a boolean is true or false, but you get a variable not found error, if your boolean is false.

This happens in some dialects that support booleans as true/false values because a value of false, similar to null/nil, is actually the absence of a value, so liquid has no value to check against.

Example LookML that could cause this:

 

dimension: falsey {

type: string

sql: false ;;

html: {% if value == true %}

style

{% else %}

other style

{% endif %}

;; }

A Solution

Use a yesno dimensions instead, or check against the rendered value (or both!)

dimension: falsey {

type: yesno

sql: case when false then no else 'yes' ;;

html: {% if rendered_value == 'yes' %}

style

{% else %}

other style

{% endif %}

;; }

This content is subject to limited support.                

Version history
Last update:
‎07-07-2021 01:14 PM
Updated by: