分类内按规则拆分一行变多行

ExcelA列是分类列,B列是由">"连接起来的多个字符串,可以看成是合并后的明细:


A

B

1

ID

Rule: Condition

2

470210642217

Test

3

470251569449

Doors & Hardware > Door Jambs> 119mm

4

470251602217

Bathroom > Stone Tops > Black Specs> 1200mm

现在要一行变多行,规则是:A不变,B列拆分成明细,像累积那样依次合并起来


A

B

7

ID

Rule: Condition

8

470210642217

Test

9

470251569449

Doors & Hardware

10

470251569449

Doors & Hardware > Door Jambs

11

470251569449

Doors & Hardware > Door Jambs> 119mm

12

470251602217

Bathroom

13

470251602217

Bathroom > Stone Tops

14

470251602217

Bathroom > Stone Tops > Black Specs

15

470251602217

Bathroom > Stone Tops > Black Specs> 1200mm

使用 SPL XLL

=spl("=?.conj(~(2).split("">"").(~=~[-1] | ~).(~.concat("">"")).([?.~(1),~]))",A2:B4)

Picture1png

conj合并子集合,split 把字符串拆分成集合,concat 反之,~ 是当前成员,~[-1] 是前一个成员,| 用于求并集。

https://stackoverflow.com/questions/78382496/split-text-into-smaller-one-and-group-by-each-id