Loading...
Loading...
Compare original and translation side by side
{{ value }}{% if condition %}valuerendered_value_filters['view.field']parameter_name._parameter_value| sql_quote_filtersTRUEFALSE| sql_boolean_in_query_is_selected{{ view.field._in_query | sql_boolean }}_in_queryrequired_fields{{ field._value }}linkGROUP BYrow['view.field']{{ value }}{% if condition %}valuerendered_value_filters['view.field']parameter_name._parameter_value_filters| sql_quoteTRUEFALSE_in_query_is_selected| sql_boolean{{ view.field._in_query | sql_boolean }}_in_queryrequired_fieldslink{{ field._value }}GROUP BYrow['view.field']_in_query_is_selected_in_query_is_selected| Variable | Definition | Critical Difference (Totals) |
|---|---|---|
| Returns | Remains |
| Returns | Returns |
[!WARNING] If you useto conditionally render logic for a dimension, that logic will fail (return false) in the Totals row. Use_is_selectedif you need the logic to persist in totals, or explicitly handle the_in_querystate for totals if that is the desired behavior.false
| 变量 | 定义 | 总计计算时的关键差异 |
|---|---|---|
| 如果字段存在于SELECT子句、筛选器或 | 如果字段为查询做出了贡献,在总计计算期间仍返回 |
| 如果字段存在于SELECT子句或 | 对于维度,在总计计算(行/列/总计行)期间返回 |
[!WARNING] 如果你使用为维度实现条件渲染逻辑,该逻辑在总计行中会失效(返回false)。如果需要逻辑在总计中保持生效,请使用_is_selected;如果希望总计行呈现false状态,请显式处理该情况。_in_query
actiondefault_valuedescriptionfiltershtmllabelview_labelgroup_labelgroup_item_labellinksqlsql_onsql_table_name| Variable | Definition | Usage |
|---|---|---|
| The raw value of the field. | A, H, LI |
| The formatted value of the field. | A, H, LI |
| The value formatted for URL filtering. | A, H, LI |
| The default drill link URL. | A, H, LI, S |
| The value with default formatting and linking. | A, H, LI |
| User filters applied to the field. | A, DE, H, LA, LI |
| Start date of a date filter. | S |
| End date of a date filter. | S |
| Applies filter logic to SQL. | S |
| Value of a parameter. | DE, LA, S |
| Injects parameter value (safe for logic). | DE, H, LA, LI, S |
| User attribute value. | A, DE, H, LA, LI, S, DV, F |
| Model name. | A, DE, H, LA, LI, S |
| View name. | A, DE, H, LA, LI, S |
| Explore name. | A, DE, H, LA, LI, S |
| Field name. | A, DE, H, LA, LI, S |
| | DE, LA, LI, S |
| | DE, LA, LI, S |
| | DE, LA, LI, S |
| | DE, LA, LI, S |
actiondefault_valuedescriptionfiltershtmllabelview_labelgroup_labelgroup_item_labellinksqlsql_onsql_table_name| 变量 | 定义 | 适用场景 |
|---|---|---|
| 字段的原始值。 | A, H, LI |
| 字段的格式化后的值。 | A, H, LI |
| 为URL筛选格式化后的值。 | A, H, LI |
| 默认钻取链接URL。 | A, H, LI, S |
| 带有默认格式与链接的值。 | A, H, LI |
| 应用于该字段的用户筛选器。 | A, DE, H, LA, LI |
| 日期筛选器的起始日期。 | S |
| 日期筛选器的结束日期。 | S |
| 为SQL应用筛选逻辑。 | S |
| 参数的值。 | DE, LA, S |
| 注入参数值(可安全用于逻辑判断)。 | DE, H, LA, LI, S |
| 用户属性值。 | A, DE, H, LA, LI, S, DV, F |
| 模型名称。 | A, DE, H, LA, LI, S |
| 视图名称。 | A, DE, H, LA, LI, S |
| Explore名称。 | A, DE, H, LA, LI, S |
| 字段名称。 | A, DE, H, LA, LI, S |
| 如果视图中的任意字段被查询,则返回 | DE, LA, LI, S |
| 如果字段存在于查询/筛选器中,则返回 | DE, LA, LI, S |
| 如果字段存在于SELECT子句中,则返回 | DE, LA, LI, S |
| 如果字段被筛选,则返回 | DE, LA, LI, S |
_in_queryview: orders {
sql_table_name:
{% if orders.created_date._in_query or orders.created_hour._in_query %}
orders_daily_summary -- Fallback to daily partition if granular date used
{% elsif orders.created_month._in_query %}
orders_monthly_summary -- Use monthly summary for high-level queries
{% else %}
orders_all_transactions -- Default/Detail table
{% endif %} ;;
}_in_queryview: orders {
sql_table_name:
{% if orders.created_date._in_query or orders.created_hour._in_query %}
orders_daily_summary -- Fallback to daily partition if granular date used
{% elsif orders.created_month._in_query %}
orders_monthly_summary -- Use monthly summary for high-level queries
{% else %}
orders_all_transactions -- Default/Detail table
{% endif %} ;;
}sql_onsql_on_in_queryexplore: order_items {
join: users {
type: left_outer
sql_on: ${order_items.user_id} = ${users.id} ;;
relationship: many_to_one
}
join: user_facts {
type: left_outer
sql_on: ${users.id} = ${user_facts.user_id} ;;
relationship: one_to_one
# Only join user_facts if a field from it is actually selected/filtered
sql_where: {% if user_facts._in_query %} 1=1 {% else %} 1=0 {% endif %} ;;
}
}sql_wheresql_on{% if %}_in_queryexplore: order_items {
join: users {
type: left_outer
sql_on: ${order_items.user_id} = ${users.id} ;;
relationship: many_to_one
}
join: user_facts {
type: left_outer
sql_on: ${users.id} = ${user_facts.user_id} ;;
relationship: one_to_one
# Only join user_facts if a field from it is actually selected/filtered
sql_where: {% if user_facts._in_query %} 1=1 {% else %} 1=0 {% endif %} ;;
}
}sql_where{% if %}sql_onmeasure: dynamic_rate {
type: number
sql:
{% if users.traffic_source._is_selected %}
${total_revenue} / NULLIF(${traffic_source_count}, 0)
{% else %}
${total_revenue} / NULLIF(${total_users}, 0)
{% endif %} ;;
}measure: dynamic_rate {
type: number
sql:
{% if users.traffic_source._is_selected %}
${total_revenue} / NULLIF(${traffic_source_count}, 0)
{% else %}
${total_revenue} / NULLIF(${total_users}, 0)
{% endif %} ;;
}dimension: status {
html:
{% if value == 'complete' %}
<span style="color: green">{{ rendered_value }}</span>
{% else %}
<span style="color: red">{{ rendered_value }}</span>
{% endif %} ;;
}dimension: status {
html:
{% if value == 'complete' %}
<span style="color: green">{{ rendered_value }}</span>
{% else %}
<span style="color: red">{{ rendered_value }}</span>
{% endif %} ;;
}view: customer_facts {
derived_table: {
sql:
SELECT customer_id, SUM(amount)
FROM orders
WHERE {% condition order_date %} created_at {% endcondition %}
GROUP BY 1 ;;
}
}view: customer_facts {
derived_table: {
sql:
SELECT customer_id, SUM(amount)
FROM orders
WHERE {% condition order_date %} created_at {% endcondition %}
GROUP BY 1 ;;
}
}view: brand_category_item {
parameter: filter { type: unquoted }
}
explore: complex_filter_parsing {
# Example: Parsing a string like "Brand1..Category1__Brand2..Category2"
# This logic splits the string by '__' then '..' to generate OR conditions
sql_where:
{% assign items = brand_category_item.filter._parameter_value | split: '__' %}
{% for item in items %}
{% assign parts = item | split: '..' %}
{% if forloop.first %} ( {% else %} OR ( {% endif %}
${products.brand} = '{{ parts[0] }}' AND ${products.category} = '{{ parts[1] }}'
)
{% endfor %}
{% if items.size == 0 %} 1=1 {% endif %}
;;
}view: brand_category_item {
parameter: filter { type: unquoted }
}
explore: complex_filter_parsing {
# Example: Parsing a string like "Brand1..Category1__Brand2..Category2"
# This logic splits the string by '__' then '..' to generate OR conditions
sql_where:
{% assign items = brand_category_item.filter._parameter_value | split: '__' %}
{% for item in items %}
{% assign parts = item | split: '..' %}
{% if forloop.first %} ( {% else %} OR ( {% endif %}
${products.brand} = '{{ parts[0] }}' AND ${products.category} = '{{ parts[1] }}'
)
{% endfor %}
{% if items.size == 0 %} 1=1 {% endif %}
;;
}