用量
视图:view_name {
measure: field_name {
required_field: [field_name, field_name, ...]
}
}
measure: field_name {
required_field: [field_name, field_name, ...]
}
}
层次结构
required_fields |
可能的字段类型
维度,衡量接受
方括号的维度和/或测量值列表 |
定义
借助 required_fields
参数,您可以在用户选择特定字段时将其他字段提取到查询中。在下面的示例中,当用户选择“关联的名称”维度时,url
字段也会提取到查询中:
dimension: linked_name {
sql: ${name} ;;
html: <a href="{{ row['websites.url'] }}" target="_new">{{ value }}</a> ;;
required_fields: [url]
}
虽然这些必需字段已添加到查询中,但它们不会向用户显示。如果必填字段更改了查询的聚合,可能会令用户感到困惑。
例如,上面的 LookML 可能会起作用,因为唯一网站名称和网站网址数量可能相同。但是,如果数据针对同一个网站名称列出了多个网址(例如将 google.com
和 google.com/news
都命名为 Google),那么可能会有多行具有相同的名称,但底层网址不同。Looker 通常会将相同的名称收拢成一行,但在此情况下,由于添加的是 url
操作,它也不会执行。