Looping over a list of Dimensions

KPIZME
New Member

So I have the following code using a combination of good ol LookML and Liquid.  What I am trying to do is loop over a list of dimensions (dimension_1, dimension_2), and have the dimension injected into a separate AND statement for every named dimension in the list.  The loop itself works, but unfortunately, the line of code generated is like this:

viewContext: agg_test._in_query | sql_boolean}} = false

Any ideas?

explore: agg_test {
  label: "Aggegate Aware Test"
  sql_always_where:
  case when {{agg_test.date._in_query}} = true
  AND {{agg_test.state._in_query}} = true
  AND {% assign attribs = '"dimension_1,dimension_2"' | split: ","  %}

  {% for item in attribs %}
    {{agg_test.{{ item }}._in_query | sql_boolean}} = false
  {% endfor %}

then attribute_3  = ‘abc’
else attribute_3  = ‘xyz’
end;;
}

0 2 1,697
2 REPLIES 2

KPIZME
New Member

For anyone that may have a similar need, I found a solution.

The looping function should be updated as follows:

{% for item in attribs %}
{{agg_test.[item]._in_query | sql_boolean}} = false
{% endfor %}

Hi @KPIZME 

Can you please share what the above code does line by line through a masked or dummy example?

Top Labels in this Space
Top Solution Authors