I use a parameter for selecting a field, i want to see in mey look/visualization like this:
parameter: pardimVar {
label: "_DimensionSwitch"
type: unquoted
allowed_value: {label: "BillingKind" value: "billingkind"}
allowed_value: {label: "BrandType" value: "brandtype"}
allowed_value: {label: "Category" value: "category"}
default_value: "category"
}
dimension: dimVar {
label: "VarDimension"
view_label: "_dynamic Dimensions"
label_from_parameter: pardimVar
sql:
{% if pardimVar._parameter_value == 'billingkind' %} ${dim_billingType.billingKindDescEng}
{% elsif pardimVar._parameter_value == 'brandtype' %} ${d_hersteller.markenart}
{% elsif pardimVar._parameter_value == 'category' %} ${d_materialklasse.category}
{% endif %}
;;
description: "use this dimension in combination with the DimensionVar Filter in the __requieredFilter!"
}
In the SQL query, which Looker generates, three joins are always generated for all three suggestions, even though I only use one join. How can I ensure that only the join that is actually used is generated?
This is a very simplified example of my application. In my actual code, I have 17 joins, which consume a huge amount of resources and make my model very slow.
Interesting question!
Have you tried referencing the fields with Liquid syntax instead of using the SQL reference syntax?
https://cloud.google.com/looker/docs/liquid-variable-reference#accessing_variables_from_other_fields