本页面提供了指向所有用于定义字段的 LookML 参数的链接。
字段有多种类型:
- 维度表示表中的列,或基于某种列操作或组合计算得出的值
- 维度组仅用于基于时间的数据,可让您一次创建多个基于时间的维度
- 测量类似于 SQL 中的聚合函数(例如
COUNT、SUM、AVG),表示多行信息 - 过滤条件会创建一个仅限过滤条件的字段,用户可以使用该字段为模板化过滤条件或条件联接提供输入
- 参数会创建一个仅限过滤条件的字段,用户可以使用该字段向 Liquid
{% parameter %}标记提供输入
用法示例
将指针悬停在参数名称上,即可查看简要说明。点击参数名称可跳转到其参考页面。
如果某个参数可以设置为多个特定选项之一,则默认值会首先列出。
## STRUCTURAL PARAMETERS view: view_name { (dimension |dimension_group |measure |filter | parameter):field_name{ intervals: [interval, interval, …] timeframes: [timeframe, timeframe, …] # ACTION AND LINKING PARAMETERS action: { label: "Label to Appear in Action Menu" url: "url" icon_url: "url" form_url: "url" param: { name: "name string" value: "value string" } # Possibly more param definitions form_param: { name: "title" type: select | string | textarea label: "desired label name" required: yes | no default: "value string" option: { name: "name string" value: "value string" } # Possibly more option definitions } # Possibly more form_param definitions } drill_fields: [field_or_set, field_or_set, ...] tags: ["string1", "string2", ...] link: { label: "desired label name;" url: "desired_url" icon_url: "url_of_an_image_file" } # Possibly more link definitions # DISPLAY PARAMETERS alias: [old_field_name, old_field_name, ...] alpha_sort: yes | no description: "description string" group_label: "desired group label name" group_item_label: "label to use under the group label in the field picker" hidden: yes | no label: "desired label name" label_from_parameter: parameter_name order_by_field: dimension_name | dimension_group_name | measure_name style: classic | interval | integer | relational view_label: "desired label name" # FILTER PARAMETERS can_filter: yes | no case_sensitive: yes | no filters: [dimension: "filter expression", dimension: "filter expression", ...] skip_drill_filter: yes | no # FILTER SUGGESTION PARAMETERS allowed_value: { label: "desired label name" value: "looker filter expression" } # Possibly more allowed_value definitions bypass_suggest_restrictions: yes | no full_suggestions: yes | no suggest_dimension: dimension_name suggest_explore: explore_name suggest_persist_for: "N (seconds | minutes | hours)" suggestable: yes | no suggestions: ["suggestion string", "suggestion string", "…"]< # QUERY PARAMETERS allow_approximate_optimization: yes | no approximate: yes | no approximate_threshold: N convert_tz: yes | no datatype: epoch | timestamp | datetime | date | yyyymmdd fanout_on: repeated_record_name precision: N primary_key: yes | no required_access_grants: [access_grant_name, access_grant_name, ...] required_fields: [field_name, field_name, ...] sql_distinct_key: SQL expression to define repeated entities ;; # VALUE AND FORMATTING PARAMETERS case: { when: { sql: SQL condition ;; label: "value" } # Possibly more when statements } default_value: "desired default value" direction: "row | column" end_location_field: dimension_name html: HTML expression using Liquid template elements ;; list_field: dimension_name percentile: Nth percentile sql: SQL expression to generate the field value ;; sql_end: SQL expression indicating the end time of a duration ;; sql_latitude: SQL expression to generate a latitude ;; sql_longitude: SQL expression to generate a longitude ;; sql_start: SQL expression indicating the start time of a duration ;; start_location_field: dimension_name synonyms: [synonym1, synonym2, ...] tiers: [N, N, ...] type: dimension_field_type # For a dimension field type: dimension_group_type # For a dimension_group field type: measure_field_type # For a measure field type: filter_field_type # For a filter field type: parameter_field_type # For a parameter field string_datatype: unicode # For a dimension field units: feet | kilometers | meters | miles | nautical_miles | yards value_format: "excel-style formatting string" value_format_name: format_name # VISUALIZATION PARAMETERS allow_fill: yes | no map_layer_name: name_of_map_layer } }
参数定义
- D = 维度
- DG = 维度组
- M = 衡量
- F = 过滤
- P = 参数
| 参数名称 | 有效字段类型 | 说明 |
|---|---|---|
| 结构参数 | ||
dimension
|
D | 创建维度字段 |
dimension_group
|
DG | 同时创建多个基于时间的维度 |
filter
|
F | 创建仅限过滤条件的字段,以便在模板化过滤条件或条件联接中使用 |
measure
|
M | 创建度量字段 |
parameter
|
P | 创建一个仅限过滤器的字段,用户可以使用该字段向 Liquid {% parameter %} 标记提供输入 |
intervals
|
DG | 定义您希望在 type: duration 的 dimension_group 中包含的时长维度集 |
timeframes
|
DG | 定义您希望在 type: time 的 dimension_group 中使用的时间范围维度集 |
| 操作和关联参数 | ||
action
|
D M | 在字段上创建数据操作,让用户可以直接在 Looker 中使用其他工具执行任务 |
drill_fields
|
D DG M | 声明在深入分析测量或维度时将显示的字段列表 |
link
|
D M | 创建指向其他 Looker 内容和外部内容的链接 |
tags
|
D DG M F P | 添加可传递给其他应用以提供字段相关数据的文本 |
| 显示参数 | ||
alias
|
D DG M F P | 允许在重命名字段后,使用旧字段名称保存的网址仍可正常运行 |
alpha_sort
|
D | 使 case 参数按字母顺序对其条件进行排序
|
description
|
D DG M F P | 为字段添加说明,用户将光标悬停在字段上时即可看到该说明。 |
group_label
|
D DG M F | 在字段选择器中将视图中的字段归为一组 |
group_item_label
|
D DG M F | 指定在字段选择器中,字段在其组标签下使用的标签 |
hidden
|
D DG M F P | 在“探索”界面中隐藏某个字段 |
label
|
D DG M F P | 更改字段名称在字段选择器中的显示方式 |
label_from_parameter
|
D M | 根据 parameter 的输入,更改字段名称在可视化图表中的显示方式 |
order_by_field
|
D DG M | 按另一个字段的值对某个字段进行排序 支持维度、维度组 支持测量 |
style
|
D | 更改分层在 Looker 界面中针对 type: tier 维度的显示方式 |
view_label
|
D DG M F P | 更改字段选择器中视图内显示的字段 |
| 过滤参数 | ||
can_filter
|
D DG M | 确定维度或测量字段是否可用作过滤条件 |
case_sensitive
|
D F | 确定过滤条件是否区分维度的大小写 |
filter
|
F | 创建一个仅限过滤条件的字段,以便在模板化过滤条件中使用 |
filters
|
M | 根据维度限制来限制测量值的计算 |
skip_drill_filter
|
D | 在深入分析度量时,阻止将维度添加到过滤条件 |
| 过滤条件建议参数 | ||
allowed_value
|
P | 指定 parameter 的选项 |
bypass_suggest_restrictions
|
D DG F P | 在使用 sql_always_where 时向用户显示建议,但不将这些限制应用于建议 |
full_suggestions
|
D DG F P | 控制 Looker 如何查询数据库,以便在探索的过滤条件中为字段值提供建议。Looker 可以使用基本的 SELECT DISTINCT 查询,也可以使用探索的完整逻辑,包括联接以及 sql_always_where 和 access_filter 参数。 |
suggest_dimension
|
D DG M F P | 根据其他维度的值提供字段建议 |
suggest_explore
|
D DG M F P | 根据其他探索的值为字段提供建议 |
suggest_persist_for
|
D F P | 更改 Looker 过滤条件建议的缓存设置 |
suggestable
|
D DG M F P | 启用或停用字段建议 |
suggestions
|
D F P | 声明将用于字段建议的值列表 |
| 查询参数 | ||
allow_approximate_optimization |
M | 允许对 type: count 或 type: count_distinct 的测量值进行非重复计数近似,以便将该测量值用于汇总感知 |
approximate |
M | 对 type: count_distinct 的度量执行近似计数。如需查看支持此参数的方言列表,请参阅 approximate 文档页面。 |
approximate_threshold
|
M | 设置 BigQuery 从精确去重计数切换到近似去重计数的计数阈值 |
convert_tz
|
D DG M F P | 停用字段的自动时区转换 |
datatype
|
D DG F M | 指定您要为字段提供的时间数据类型 |
fanout_on
|
D DG M | 允许访问 Google BigQuery 重复字段 |
precision
|
M | 指定在计算 Looker 对称聚合时要使用的小数位数 |
primary_key
|
D | 将某个维度声明为视图的主键 |
required_access_grants |
D DG F M P | 仅限用户属性值与访问权限匹配的用户访问该字段 |
required_fields
|
D M | 要求在选择某个字段时向查询添加其他字段 |
sql_distinct_key
|
M | 定义用于计算 type: sum_distinct 或 type: average_distinct 衡量指标的唯一实体 |
| 值和格式设置参数 | ||
case
|
D | 创建维度可具有的一组离散值,这些值由 SQL 条件确定 |
default_value
|
F P | 为过滤条件字段指定默认值 |
direction
|
M | 确定使用透视时计算 type: percent_of_total 或 type: running_total 测量值的方向 |
end_location_field
|
D | 定义包含 type: distance 字段的结束位置的字段 |
html
|
D DG M | 使用 Liquid 模板修改字段的 HTML 输出 |
list_field
|
M | 声明用于计算 type: list 测量值的维度 |
percentile
|
M | 为 type: percentile 或 type: percentile_distinct 类型的测量指定分数值(第 N 个百分位) |
sql
|
D DG M F | 确定字段的计算方式 |
sql_end
|
D DG | 为时长类型维度组或时长类型维度定义时长的结束时间 |
sql_latitude
|
D | 定义 type: location 维度的纬度 |
sql_longitude
|
D | 定义 type: location 维度的经度 |
sql_start
|
D DG | 为时长类型维度组或时长类型维度定义时长的开始时间 |
start_location_field
|
D | 定义包含 type: distance 字段的起始位置的字段 |
synonyms
|
D DG F M P | 指定一个字符串同义词(字词或短语)列表,这些同义词可用于帮助大语言模型和应用开发者了解用户可能用来指代某个字段的其他方式 |
tiers
|
D | 定义 type: tier 维度的层级 |
type(适用于维度、过滤条件或参数)
|
D F P | 指定维度、过滤条件或参数的类型 |
type(适用于维度组)
|
DG | 指定维度组的类型 |
type(针对测量)
|
M | 指定度量类型 |
string_datatype
|
D | 为 SQL Server 或 MySQL 的 type: string 字段指定 Unicode 数据类型 |
units
|
D | 指定要用于 type: distance 字段的单位 |
value_format
|
D M | 使用 Excel 样式选项设置字段输出的格式 |
value_format_name
|
D M | 使用内置或自定义格式设置字段输出的格式 |
| 可视化参数 | ||
allow_fill
|
D DG | 确定是否允许对维度进行维度填充 |
map_layer_name
|
D | 指定从数据值到您在内置地图或自定义地图上定义的地理区域的映射 |
| 要避免的参数 | ||
decimals
|
D M |
已在 5.4 中移除
替换为 value_format
|
format
|
D M |
已在 3.16 中移除
替换为 value_format |