如何将一列按水平方向排序成具有匹配前缀的转置行?

huangapple go评论56阅读模式
英文:

How can I sort a column horizontally into transposed rows with matching prefixes?

问题

我有一个Google表格的列,数据看起来像这样。带有计数后缀的ID号码。如何将它们水平转置为行,然后在表格中按其ID号码排序/分组/筛选,以匹配其后缀号码的适当列数?

表格链接:
https://docs.google.com/spreadsheets/d/1wq3Zrh5wE_IHP2utvMeFRHrMe1qra2ppq_G7PrSt-jY/edit?usp=sharing

我所拥有的
INV46673-1
INV46673-2
INV56184-1
INV56184-2
INV56184-3
INV56184-4
INV56184-5
INV68328-1
INV68328-2
INV68328-3
INV68328-4
INV68347-1
INV68347-2
INV68347-3
我所需要的
INV46673-1 INV46673-2
INV56184-1 INV56184-2 INV56184-3 INV56184-4 INV56184-5
INV68328-1 INV68328-2 INV68328-3 INV68328-4
INV68347-1 INV68347-2 INV68347-3

如果表格有一个现成的功能来实现这个,我尚未找到它。我尝试过数据透视表、Hlookup、筛选数组等等。我会感激任何建议。使用固定字符计数(8)的解决方案可以工作,但我希望看到一些实际使用确切ID号码的东西。

英文:

I have a google sheet column with data that looks like this. ID numbers with count suffixes. How can I transpose them horizontally into rows on a sheet sorted/grouped/filtered by their ID number into the appropriate number of columns matching their suffix number?

Sheet Link:
https://docs.google.com/spreadsheets/d/1wq3Zrh5wE_IHP2utvMeFRHrMe1qra2ppq_G7PrSt-jY/edit?usp=sharing

What I have
INV46673-1
INV46673-2
INV56184-1
INV56184-2
INV56184-3
INV56184-4
INV56184-5
INV68328-1
INV68328-2
INV68328-3
INV68328-4
INV68347-1
INV68347-2
INV68347-3
What I need
INV46673-1 INV46673-2
INV56184-1 INV56184-2 INV56184-3 INV56184-4 INV56184-5
INV68328-1 INV68328-2 INV68328-3 INV68328-4
INV68347-1 INV68347-2 INV68347-3

If sheets has an off the shelf function for this I have not been able to find it. I have tried pivot tables, Hlookup, filtered arrays etc. I am grateful for any advice I may receive. A solution that uses a fixed character count (8) will work but I would love to see something that actually uses the exact ID number.

答案1

得分: 0

尝试以下公式-

=INDEX(SPLIT(BYROW(UNIQUE(INDEX(SPLIT(A2:A15,"-"),,1)),LAMBDA(x,JOIN("|",SORT(FILTER(A2:A15,INDEX(SPLIT(A2:A15,"-"),,1)=x))))),"|"))

如何将一列按水平方向排序成具有匹配前缀的转置行?

英文:

Try the following formula-

=INDEX(SPLIT(BYROW(UNIQUE(INDEX(SPLIT(A2:A15,"-"),,1)),LAMBDA(x,JOIN("|",SORT(FILTER(A2:A15,INDEX(SPLIT(A2:A15,"-"),,1)=x))))),"|"))

如何将一列按水平方向排序成具有匹配前缀的转置行?

答案2

得分: 0

以下是您要翻译的内容:

这里有另一种方法:

=index(let(a,regexextract(A2:index(A:A,counta(A:A)),"(.*)-(\d+)"),b,unique(index(a,,1)),c,max(--index(a,,2)),makearray(counta(b),c,lambda(r,x,xlookup(index(b,r)&"-"&index(sequence(1,c),,x),A:A,A:A))))

如何将一列按水平方向排序成具有匹配前缀的转置行?

英文:

Here's another approach:

=index(let(a,regexextract(A2:index(A:A,counta(A:A)),"(.*)-(\d+)"),b,unique(index(a,,1)),c,max(--index(a,,2)),makearray(counta(b),c,lambda(r,x,xlookup(index(b,r)&"-"&index(sequence(1,c),,x),A:A,A:A,)))))

如何将一列按水平方向排序成具有匹配前缀的转置行?

huangapple
  • 本文由 发表于 2023年2月19日 12:59:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75498103.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定