0
0

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 3 years have passed since last update.

TD Presto関数 #1(MAX BY, SPLIT)

Last updated at Posted at 2022-06-14

備忘録としてTreasue Dataで使用したPretoの関数を記載しておきます。

MAX BY(A, B)

B列が最新の値の場合のA列を反映する

最新timeのguid列を反映
MAX BY(guid, time) as time

SPLIT(string, '記号')[n]

'記号'で区切られているstring列の値から、n番目の値を反映する。
例えばcategoryというカラムに以下のように/で区切られた値がある場合

category
FURNITURE/KITCHEN/CHAIR
SPLIT(category, '/')[2] as test

抽出結果は以下のようになります。

SPLIT
KITCHEN

※ちなみに数字を[]で指定しないと結果は以下のようになります。

SPLIT(数字指定しない場合)
["FURNITURE","KITCHEN","CHAIR"]
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?