WPS / EXCLE 可用
- =LET(
- array, Sheet1!$A$2:$C$17,
- filterByCol, LAMBDA(findCol, findVal, FILTER(array, INDEX(array, , findCol) = findVal)),
- getPath, LAMBDA(self, foundRows, [i], [curPath],
- LET(
- i, i + 1,
- endStation, INDEX(foundRows, i, 2),
- roadName, INDEX(foundRows, i, 3),
- nextRows, filterByCol(1, endStation),
- fullPath, IF(
- NOT(OR(ISERROR(nextRows))),
- self(self, nextRows, 0, curPath & "-" & roadName),
- curPath & "-" & roadName
- ),
- IF(
- i < ROWS(foundRows),
- fullPath & ";" & self(self, foundRows, i, curPath),
- fullPath
- )
- )
- ),
- isFirstStation, LAMBDA(row, ISERROR(MATCH(INDEX(row, , 1), INDEX(array, , 2), 0))),
- loopRows, LAMBDA(self, [i],
- LET(
- i, i + 1,
- path, if(
- isFirstStation(INDEX(array, i,)),
- getPath(getPath, filterByCol(3, INDEX(array, i, 3))),
- ""
- ),
- IF(i < ROWS(array), path & ";" & self(self, i), path)
- )
- ),
- result, loopRows(loopRows),
- IFERROR(TEXTSPLIT(result, "-", ";", TRUE), "")
- )
复制代码
|