4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TableauでBigQueryのTABLE_DATE_RANGEを使う方法

Posted at

TableauでデータソースをGoogle Bigqueryにする際にTABLE_DATE_RANGEを使いたい!
そうじゃないと毎回フルスキャンでコストが・・・。なんてことにならないように

前提

BigQueryのテーブルは以下のような形でyyyymmddが入っているとします

  • weblog_20161118
  • weblog_20161119
  • weblog_20161120

手順

それではTableauの設定手順です。

パラメータを作成

Tableauで参照する日付のFrom(開始)とTo(終了)を作成します。

tableau1.png

カスタムSQLでパラメータを埋め込む

from_date, to_dateのパラメータを使い、以下のようなSQL設定します

SELECT
  *
FROM (
  TABLE_DATE_RANGE(
    [dataset].weblog_,
    TIMESTAMP(<パラメーター.from_date>),
    TIMESTAMP(<パラメーター.to_date>)
   )
)

あとはパラメーターコントロールを表示してあげれば完了です。

tableau2.png

さいごに

パラメータは直接入力です。(なんでも指定可能です)
存在している日付だけ指定できるようになんとか改善したいものです。

というか、こんな形ではなくもっとスマートにできる方法があれば教えてください

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?