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

文字列を連結して1行で表示

Posted at

はじめに

Tableauでは、文字列フィールドに対してMAX(最大値)・COUNTD(一意な数)等の集計はできますが、すべてのデータの文字列を連結するといったことはできません。
今回は指定したフィールドの文字列を連結して1行で表示する方法を紹介いたします。

使用するデータソース

サンプルスーパーストア

目的

「カテゴリ」ごとに「サブカテゴリ」を連結して1行で表示する
image.png

実装

手順1

「サブカテゴリ(連結)」フィールドを作成
PREVIOUS_VALUE():表計算関数であり、一つ前の計算結果を返します

PREVIOUS_VALUE('')
+IIF(FIRST()=0,'',',')
+MAX([サブカテゴリ])

手順2

「LASTフィルター」フィールドを作成

LAST()=0

手順3

ビューに配置
行:カテゴリ、サブカテゴリ
ラベル:サブカテゴリ(連結)
image.png
※「サブカテゴリ(連結)」の設定:「次を使用して計算」⇒「サブカテゴリ」
image.png

手順4

「LASTフィルター」をフィルターに配置して「真」を選択
※「サブカテゴリ(連結)」の設定:「次を使用して計算」⇒「サブカテゴリ」
image.png

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