I built a parameter and a measure which run SQL from a joined view, but when I run it in Explore, I get an error: "No such field joined_view.field1"
view: viewA {
.
.
.
parameter: selection_field {
type: unquoted
allowed_value: {
label: "1"
value: "field1"
}
allowed_value: {
label: "2"
value: "field2"
}
allowed_value: {
label: "3"
value: "field3"
}
}
measure: dynamic_count {
type: count_distinct
label: "Selection"
sql:
${joined_view.{% parameter selection_field %}};;
}
}
When I try (below), it runs successfully. How to deal with it? Thanks for your help.
measure: count {
type: count_distinct
sql:
${joined_view.field1};;
}
You try this code in you sql part of measure:
{% if date_granularity._parameter_value == 'field1' %}
${joinedview.field1}
{% elsif date_granularity._parameter_value == 'field2' %}
${joinedview.field2}
{% else %}
${joinedview.field3}
{% endif %};;
Hey there,
One way is to follow the hint from our colleague above (it is also a bit harder to get that wrong since the LookML validator will complain if you miss something).
But the main issue here is that you are trying to concatenate two variables, so I suggest that instead of
${joined_view.{% parameter selection_field %}};;
You do
${joined_view}.{% parameter selection_field %};;
That would treat the variables separately where the first will bring the alias of the table and the second will bring the name of the column.