0
1

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.

metabaseでフィールドフィルターを使わずに任意の月基準のデータを表示する

Posted at

自分用メモ
フィールドフィルター使えない状況の対処
ポスグレ使用環境

1.テキストで指定する場合

フィルターをテキストに設定して YYYY/MM で年月を入力して使うようにする
【指定月の表示】
to_char(date, 'YYYY/MM') = {{text}}

2.日付で指定する場合

キャストしないとエラる
【指定月の表示】
date_trunc('month', date) = date_trunc('month', cast({{day}} as timestamp))
【指定月から一ヶ月前までの表示】
date_trunc('month', date) between date_trunc('month', date_trunc('month', cast({{day}} as timestamp)) - interval '1 day') and date_trunc('month', cast({{day}} as timestamp))

ex.当月をデフォルト値にしたい場合

指定した時だけ当月指定の記述をコメントアウトするようにすればおk
date_trunc('month', date) = [[date_trunc('month', cast({{day}} as timestamp)) --]]date_trunc('month', current_timestamp)

フィールドフィルター以外でももうちょっとフィルターの幅増やして欲しい

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?