
行方向のみに条件が並ぶ表を、行・列方向に条件が並ぶ表に変換する
今回は、こちらの話題の逆変換です。
こんな感じの、左側に条件が並んでいる一覧表があるとします。
例-1

例-2

これを、タイトル行・列の2方向に条件が並ぶ表に変換します。

「例-1」のような場合
(1) 1つめの条件を行方向に並べ替える
重複をなくす数式「unique()」を使えば1発で処理できる

引数には、条件の範囲(赤色の範囲)を指定する
=unique([条件の範囲])
すると、次のような感じに変換できる

(2) 2つめの条件を列方向に並べ替える
(1)の処理に、転置するための数式「transpose()」を付け加えて使う

引数には、条件の範囲(青色の範囲)を指定する
=transpose(unique([条件の範囲]))
すると、次のような感じに変換できる

(3) 対応値を行・列方向に整理しなおす
「tocol()」の逆変換をする数式「wraprows()」を使う

引数には、条件の範囲(黄色の範囲)と、列数を入れる
=wraprows([対応値の範囲],[列数])
すると、次のような感じに変換できる

「例-2」のような場合
(1) 条件を分解し、その1つめを行方向に並べ替える
まず、文字列をセル分割する数式「split()」を使う
そのあと、セル列を取り出す数式「index()」を合わせて使う
(splitの第1引数には分割対象文字列、第2引数には区切り文字を入れ、
indexの第1引数には行番(今回は空欄)、第2引数には列番を入れる)
その上で、重複をなくす数式「unique()」を使う

引数には、条件の範囲(緑色の範囲)を指定する
(「"-"」のところは、区切り文字に応じて変わってきます)
=unique(index(split([条件の範囲],"-"),,1))
すると、次のような感じに変換できる

(2) 条件を分解し、その2つめを列方向に並べ替える
(1)の処理に、転置するための数式「transpose()」を付け加えて使う

引数には、条件の範囲(緑色の範囲)を指定する
(「"-"」のところは、区切り文字に応じて変わってきます)
=transpose(unique(index(split([条件の範囲],"-"),,2)))
すると、次のような感じに変換できる

(3) 対応値を行・列方向に整理しなおす
上記の、「例-1」のような場合の(3)と同じ
以上のことを組み合わせれば、次のような表ができあがります。
機会があれば、せひ活用していきましょう!
