欄位參數

這個頁面會連結至所有定義欄位的 LookML 參數。

欄位分為以下幾種類型:

  • 維度代表資料表中的資料欄,或是根據某種資料欄操控或組合計算出的值
  • 維度群組僅適用於時間資料,可讓您一次建立多個時間維度
  • 測量與 SQL 中的匯總函式 (例如 COUNTSUMAVG) 類似,代表多個資料列的相關資訊
  • 篩選器會建立僅供篩選的欄位,使用者可透過這些欄位為範本化篩選器條件式聯結提供輸入內容
  • 參數會建立篩選器限定欄位,供使用者提供 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 = Filter
  • P = 參數
參數名稱 有效欄位類型 說明
結構參數
dimension D 建立維度欄位
dimension_group DG 同時建立多個時間維度
filter F 建立篩選器限定欄位,用於範本化篩選器或條件式聯結
measure M 建立測量指標欄位
parameter P 建立僅限篩選器的欄位,供使用者為 Liquid {% parameter %} 標記提供輸入內容
intervals DG 定義您要在 dimension_group 中的 type: duration 期間維度集。
timeframes DG 定義您要在 dimension_grouptype: time 中使用的時間範圍維度集
動作和連結參數
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 Makes a case parameter sort its conditions alphabetically
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 在探索 UI 中隱藏欄位
label D DG M F P 變更欄位名稱在欄位挑選器中的顯示方式
label_from_parameter D M 根據 parameter 的輸入內容,變更欄位名稱在資料視覺化中的顯示方式
order_by_field D DG M

依據另一個欄位的值排序欄位

支援維度、維度群組

支援的測量指標

style D 變更 Looker UI 中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_whereaccess_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: counttype: 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_distincttype: average_distinct 測量的專屬實體
值和格式設定參數
case D 根據 SQL 條件建立維度可擁有的離散值集
default_value F P 指定篩選條件欄位的預設值
direction M 決定使用樞紐時,type: percent_of_totaltype: running_total 的計算方向
end_location_field D 定義包含 type: distance 欄位結束位置的欄位
html D DG M 使用 Liquid 範本修改欄位的 HTML 輸出內容
list_field M 宣告要計算 type: list 測量的維度
percentile M 指定 type: percentiletype: 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