named_value_format

使用状況

named_value_format: desired_name
階層
named_value_format
デフォルト値
なし

許可
カスタム形式の名前に、形式を定義する Excel スタイルの書式設定文字列とオプションの strict_value_format サブパラメータのブール値を指定します。

定義

named_value_format パラメータを使用すると、複数のディメンションとメジャーに適用できるカスタム フォーマットを作成して保存できます。

Looker のカスタム形式は、いくつかのステップで作成され、使用されます。

  1. まず、モデルファイルで named_value_format を使用して、新しいカスタム形式の名前を宣言します。この名前は、スペースを含まない文字列にする必要があります。
  2. 次に、named_value_format の下にある value_format サブパラメータを使用して、Excel 形式の書式設定文字列を指定して、必要な形式を定義します。
  3. 最後に、フィールド レベルの value_format_name パラメータで参照することにより、このカスタム形式をディメンションとメジャーに適用します。

下記ののように、モデルには複数のカスタム形式を定義できます。

一般的な value_format 書式設定文字列

value_format パラメータで使用する書式は、visualizationValue Format フィールドで使用する書式と同じですが、value_format パラメータでは書式設定文字列を二重引用符で囲む必要があります。ビジュアリゼーション内の値のフォーマットについては、縦棒グラフのオプションをご覧ください。

これらの形式を指定する方法については、Excel のドキュメントをご覧ください。ただし、現時点で Looker では日付の書式設定、色の書式設定、16 進変換はサポートされていません。

もっともよく使われる書式設定オプションのいくつかを、以下に示します。 一部の通貨(国際通貨記号など)は二重引用符で囲む必要があります。

value_format: "0"             # Integer (123)
value_format: "*00#"          # Integer zero-padded to 3 places (001)
value_format: "0 \" String\"" # Integer followed by a string (123 String)
                              #   Please note "String" can be replaced with any other word

value_format: "0.##"          # Number up to 2 decimals (1. or 1.2 or 1.23)
value_format: "0.00"          # Number with exactly 2 decimals (1.23)
value_format: "*00#.00"       # Number zero-padded to 3 places and exactly 2 decimals (001.23)
value_format: "#,##0"         # Number with comma between thousands (1,234)
value_format: "#,##0.00"      # Number with comma between thousands and 2 decimals (1,234.00)
value_format: "0.000,,\" M\"" # Number in millions with 3 decimals (1.234 M)
                              #   Please note division by 1 million happens automatically
value_format: "0.000,\" K\""  # Number in thousands with 3 decimals (1.234 K)
                              #   Please note division by 1 thousand happens automatically

value_format: "$0"            # Dollars with 0 decimals ($123)
value_format: "$0.00"         # Dollars with 2 decimals ($123.00)
value_format: "\"€\"0"        # Euros with 0 decimals (€123)
value_format: "$#,##0.00"     # Dollars with comma btwn thousands and 2 decimals ($1,234.00)
value_format: "$#.00;($#.00)" # Dollars with 2 decimals, positive values displayed
                              #   normally, negative values wrapped in parenthesis

value_format: "0\%"           # Display as percent with 0 decimals (1 becomes 1%)
value_format: "0.00\%"        # Display as percent with 2 decimals (1 becomes 1.00%)
value_format: "0%"            # Convert to percent with 0 decimals (.01 becomes 1%)
value_format: "0.00%"         # Convert to percent with 2 decimals (.01 becomes 1.00%)

strict_value_formatnumber_format ユーザー属性をオーバーライドします

通常、number_format ユーザー属性で設定された数値の形式は、named_value_format で作成された形式で適用されます。ただし、オプションの strict_number_format サブパラメータを yes に設定すると、number_format の書式は適用されず、項目では named_value_format の書式が保持されます。例と詳細については、数値の形式をローカライズするをご覧ください。

デフォルトの書式設定オプション

Looker の組み込み値のいずれかの形式を適用する場合は、value_format_name パラメータのドキュメント ページのデフォルトの形式の名前に記載されている形式から選択します。value_format_name を使用して組み込みフォーマットを適用する手順については、このページをご覧ください。

€1.23K のような euro_in_thousands というカスタム フォーマットを作成します。

named_value_format: euro_in_thousands {
  value_format: "\"€\"0.000,\" K\""
}

number_formatting ユーザー属性が euro_in_thousands 形式に影響を与えないようにします。

named_value_format: euro_in_thousands {
  value_format: "\"€\"0.000,\" K\""
  strict_value_format: yes
}

別の例については、数値形式のローカライズのページもご覧ください。

$123M というカスタム フォーマットと (123) 456-7890 のような phone_number というカスタム フォーマットを作成します。

named_value_format: usd_in_millions {
  value_format: "$0.000,,\" M\""
}
named_value_format: phone_number {
  value_format: "(###) ###-####"
}