用量
view: view_name {
measure: field_name {
required_fields: [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]
}
雖然查詢中會加入必填欄位,但不會向使用者顯示。如果必要欄位會變更查詢的匯總,使用者可能會感到困惑。
顯示 url 為必填欄位的 LookML 範例可能適用,因為網站名稱和網址的數量可能相同。不過,如果資料列出相同網站名稱的多個網址 (例如將 google.com 和 google.com/news 都命名為「Google」),則可能有多個資料列的名稱相同,但基礎網址不同。Looker 通常會將相同的名稱摺疊成一個資料列,但在此情況下不會,因為 Looker 會將 url 欄位視為已新增。