用途
named_value_format: desired_name {
value_format: "excel formatting string"
strict_value_format: yes | no
}
|
階層
named_value_format |
デフォルト値
なし
許可
カスタム形式の名前と、形式を定義する Excel 形式の書式設定文字列、オプションの strict_value_format サブパラメータのブール値 |
定義
named_value_format パラメータを使用すると、複数のディメンションとメジャーに適用できるカスタム形式を作成して保存できます。
Looker でカスタム形式を作成して使用する手順は次のとおりです。
- まず、モデルファイルで
named_value_formatを使用して、新しいカスタム形式の名前を宣言します。この名前は、スペースを含まない文字列にする必要があります。 - 次に、
value_formatサブパラメータをnamed_value_formatの下で使用して、Excel 形式の書式設定文字列 を指定し、必要な形式を定義します。 - 最後に、フィールドレベルで
value_format_nameパラメータで参照して、このカスタム形式をディメンションとメジャーに適用します。
次の例に示すように、モデルで複数のカスタム形式を定義できます。
一般的な value_format 書式設定文字列
value_formatパラメータで使用される形式は、可視化の [Value 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_format は number_format ユーザー属性をオーバーライドする
通常、number_format ユーザー属性で設定された数値形式は、named_value_format で作成された形式に加えて適用されます。ただし、オプションの strict_number_format サブパラメータを yes に設定すると、number_format の形式は適用されず、フィールドは named_value_format の形式を保持します。例と詳細については、数値書式のローカライズのドキュメント ページをご覧ください。
デフォルトの書式設定オプション
Looker の組み込み値形式のいずれかを適用する場合は、デフォルトの形式名のセクションに記載されている形式から選択できます。value_format_namevalue_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
}
別の例については、数値書式のローカライズのドキュメント ページもご覧ください。
usd_in_millions というカスタム形式と、$1.23M のような phone_number という形式と、(123)456-7890 のような形式を作成します。
named_value_format: usd_in_millions {
value_format: "$0.000,,\" M\""
}
named_value_format: phone_number {
value_format: "(###) ###-####"
}