🇺🇸More Powerful Data Drilling🇺🇸
Lookerのユニークな点の一つは、データベースに直接接続するところです。これは、常に新鮮なデータにアクセスでき かつ 常に最も細かい粒度のレベルまでドリルダウンできる事を意味します。そのため、もちろん年次や月次のサマリーを見ることができますが、Lookerは日、時間や秒にまで瞬時にドリルダウンするオプションを提供します。
常時のカテゴリ概要からはじめ、次に1つのカテゴリ(ジーンズ)の月次売上チャートにドリルダウンするのを以下で見ることができます。
しかし、LookerのWebネイティブのモダンなアーキテクチャは、1つのレベルから次の粒度までドリルダウンするだけでなく、もっと多くを実現できる事を意味しています。いくつかの簡単なパラメータを利用して、ユーザーが望む洗練されているカスタムドリルパスを構築することができます。
これを実証するために、以下で最も一般的なドリルパターンのいくつかのサンプルコードを作成しました。:
最初の20件の結果を表示する
measure: returned_count {
type: count_distinct
sql: ${id} ;;
filters: {
field: is_returned
value: "yes"
}
drill_fields: [detail*]
link: {label: "Explore Top 20 Results" url: "{{ link }}&limit=20" }
}
売上上位20件を表示する
measure: returned_count {
type: count_distinct
sql: ${id} ;;
filters: {
field: is_returned
value: "yes"
}
drill_fields: [detail*]
link: {label: "Explore Top 20 Results by Sale Price" url: "{{ link }}&sorts=order_items.sale_price+desc&limit=20" }
}
各年齢の年と粗利益率の階層を表示する
measure: order_count {
type: count_distinct
drill_fields: [created_year, item_gross_margin_percentage_tier, users.age_tier, total_sale_price]
link: {label: "Total Sale Price by Month for each Age Tier" url: "{{link}}&pivots=users.age_tier"}
sql: ${order_id} ;;
}
これは、データを見るのに適していますがビジュアライズする場合はどうでしょうか?Lookerは Visual Drilling と呼ばれるベータ機能があり、ユーザーはチャートをドリルダウンできます。カスタマイズせずに、限られたドリルセットにより、様々なビジュアリゼーションを取得できます。
日別に販売したアイテム数を表示する
measure: count {
type: count_distinct
sql: ${id} ;;
drill_fields: [created_date, total_sale_price]
}
ビジュアルドリルダウンは、単純なアプローチに基づいていましたが、次はLookerが表示するビジュアライゼーションをどのように制御できますか?という質問です。
30日間の移動平均で1日に販売したアイテム数を表示する
measure: count {
type: count_distinct
sql: ${id} ;;
drill_fields: [created_date, total_sale_price]
link: {
label: "Show as scatter plot"
url: "
{% assign vis_config = '{
\"stacking\" : \"\",
\"show_value_labels\" : false,
\"label_density\" : 25,
\"legend_position\" : \"center\",
\"x_axis_gridlines\" : true,
\"y_axis_gridlines\" : true,
\"show_view_names\" : false,
\"limit_displayed_rows\" : false,
\"y_axis_combined\" : true,
\"show_y_axis_labels\" : true,
\"show_y_axis_ticks\" : true,
\"y_axis_tick_density\" : \"default\",
\"y_axis_tick_density_custom\": 5,
\"show_x_axis_label\" : false,
\"show_x_axis_ticks\" : true,
\"x_axis_scale\" : \"auto\",
\"y_axis_scale_mode\" : \"linear\",
\"show_null_points\" : true,
\"point_style\" : \"circle\",
\"ordering\" : \"none\",
\"show_null_labels\" : false,
\"show_totals_labels\" : false,
\"show_silhouette\" : false,
\"totals_color\" : \"#808080\",
\"type\" : \"looker_scatter\",
\"interpolation\" : \"linear\",
\"series_types\" : {},
\"colors\": [
\"palette: Santa Cruz\"
],
\"series_colors\" : {},
\"x_axis_datetime_tick_count\": null,
\"trend_lines\": [
{
\"color\" : \"#000000\",
\"label_position\" : \"left\",
\"period\" : 30,
\"regression_type\" : \"average\",
\"series_index\" : 1,
\"show_label\" : true,
\"label_type\" : \"string\",
\"label\" : \"30 day moving average\"
}
]
}' %}
{{ link }}&vis_config={{ vis_config | encode_uri }}&toggle=dat,pik,vis&limit=5000"
}
}
リキッド変数を使ってLookerのビジュアライゼーション設定にURLを渡します。
これらの設定はビジュアルドリルモーダルを制御します。次にいくつかの例を示します。
measure: total_sale_price {
type: sum
value_format_name: usd
sql: ${sale_price} ;;
drill_fields: [total_sale_price, created_month_name, created_year]
link: {
label: "Show as stacked line"
url: "
{% assign vis_config = '{
\"stacking\" : \"normal\",
\"legend_position\" : \"right\",
\"x_axis_gridlines\" : false,
\"y_axis_gridlines\" : true,
\"show_view_names\" : false,
\"y_axis_combined\" : true,
\"show_y_axis_labels\" : true,
\"show_y_axis_ticks\" : true,
\"y_axis_tick_density\" : \"default\",
\"show_x_axis_label\" : true,
\"show_x_axis_ticks\" : true,
\"show_null_points\" : false,
\"interpolation\" : \"monotone\",
\"type\" : \"looker_line\",
\"colors\": [
\"#5245ed\",
\"#ff8f95\",
\"#1ea8df\",
\"#353b49\",
\"#49cec1\",
\"#b3a0dd\"
],
\"x_axis_label\" : \"Month Number\"
}' %}
{{ link }}&vis_config={{ vis_config | encode_uri }}&sorts=order_items.created_year+asc,order_items.created_month_name+asc&pivots=order_items.created_year&toggle=dat,pik,vis&limit=500&column_limit=15"
} # NOTE the &pivots=
}
measure: average_shipping_time {
type: average
value_format_name: decimal_2
sql: ${shipping_time} ;;
drill_fields: [products.category, users.age_tier, average_shipping_time]
link: { label: "See as custom viz (heatmap)"
url: "
{% assign vis_config = '{
\"minColor\" : \"#d6d6d6\",
\"maxColor\" : \"#9a33e3\",
\"dataLabels\" : false,
\"custom_color_enabled\" : false,
\"custom_color\" : \"forestgreen\",
\"show_single_value_title\": true,
\"show_comparison\" : false,
\"comparison_type\" : \"value\",
\"comparison_reverse_colors\": false,
\"show_comparison_label\" : true,
\"show_view_names\" : true,
\"show_row_numbers\" : true,
\"truncate_column_names\" : false,
\"hide_totals\" : false,
\"hide_row_totals\" : false,
\"table_theme\" : \"editable\",
\"limit_displayed_rows\" : false,
\"enable_conditional_formatting\": false,
\"conditional_formatting_include_totals\": false,
\"conditional_formatting_include_nulls\": false,
\"type\" : \"highcharts_heatmap\",
\"stacking\" : \"\",
\"show_value_labels\" : false,
\"label_density\" : 25,
\"legend_position\" : \"center\",
\"x_axis_gridlines\" : false,
\"y_axis_gridlines\" : true,
\"y_axis_combined\" : true,
\"show_y_axis_labels\" : true,
\"show_y_axis_ticks\" : true,
\"y_axis_tick_density\" : \"default\",
\"y_axis_tick_density_custom\": 5,
\"show_x_axis_label\" : true,
\"show_x_axis_ticks\" : true,
\"x_axis_scale\" : \"auto\",
\"y_axis_scale_mode\" : \"linear\",
\"ordering\" : \"none\",
\"show_null_labels\" : false,
\"show_totals_labels\" : false,
\"show_silhouette\" : false,
\"totals_color\" : \"#808080\",
\"series_types\" : {},
\"hidden_fields\" : [
\"order_items.count\",
\"order_items.total_sale_price\"
]
}' %}
{{ link }}&vis_config={{ vis_config | encode_uri }}&sorts=products.category+asc,users.age_tier+asc&toggle=dat,pik,vis&limit=5000"
}
}
measure: total_sale_price {
type: sum
value_format_name: usd
sql: ${sale_price} ;;
drill_fields: [created_month, users.gender, total_sale_price]
link: {
label: "Table Calc & Total"
url: "
{% assign table_calc = '[
{ \"table_calculation\": \"percent_of_total\",
\"label\": \"Percent of Total\",
\"expression\": \"${order_items.total_sale_price:row_total} / sum(${order_items.total_sale_price:row_total})\",
\"value_format\": null,
\"value_format_name\": \"percent_2\",
\"_kind_hint\": \"supermeasure\",
\"_type_hint\": \"number\"
},
{ \"table_calculation\": \"growth_rate\",
\"label\": \"Growth Rate\",
\"expression\": \"${order_items.total_sale_price} / offset(${order_items.total_sale_price},1) - 1\",
\"value_format\": null,
\"value_format_name\": \"percent_2\",
\"_kind_hint\": \"measure\",
\"_type_hint\": \"number\"
}]' %}
{% assign vis_config = '{
\"type\": \"table\",
\"show_view_names\": false,
\"show_row_numbers\": false,
\"truncate_column_names\": false,
\"table_theme\": \"gray\",
\"enable_conditional_formatting\": true,
\"conditional_formatting\": [
{
\"type\": \"low to high\",
\"value\": null,
\"background_color\": null,
\"font_color\": null,
\"palette\": {
\"name\": \"Custom\",
\"colors\": [
\"#FFFFFF\",
\"#6e00ff\"
]},
\"bold\": false,
\"italic\": false,
\"strikethrough\": false,
\"fields\": [
\"growth_rate\"
]},{
\"type\": \"low to high\",
\"value\": null,
\"background_color\": null,
\"font_color\": null,
\"palette\": {
\"name\": \"Custom\",
\"colors\": [
\"#FFFFFF\",
\"#88ff78\"
]},
\"bold\": false,
\"italic\": false,
\"strikethrough\": false,
\"fields\": [
\"percent_of_total\"
]}]}' %}
{{link}}&total=on&row_total=right&dynamic_fields={{ table_calc | replace: ' ', '' | encode_uri }}&pivots=users.gender&vis_config={{ vis_config | replace: ' ', '' | encode_uri }}"
}
}