如何在 Google 工作表中合并具有不同值的相同索引的行?

How tp merge rows with same index with different values in Google Sheets?

我有一个电子表格,其中包含名为 uniqueStyle 的索引和多列。 uniqueStyle 有多个 sizeprimaryImg-src。我想折叠它们具有相同 uniqueStyle 的行,每个尺寸和 img-src 在其自己的单元格中。

这是我的示例:

uniqueStyle   dressTitle      size        imageSrc
CH1506        Lace Bodice Sateen Sheath Dress   
CH1506                              S   
CH1506                              M   
CH1506                              L   
CH1506                              XL  
CH1506                              2X  
CH1506                              3X  
CH1506                                              /image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506_2_.jpg
CH1506                                              /image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506.jpg
CH1506                                              /1/image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506_3_.jpg
CH1506                                                  /1/image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506_4_.jpg

所需的结果输出:

uniqueStyle         dressTitle                      size                imageSrc
CH1506              Lace Bodice S..                 S        /image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506_2_.jpg
CH1506                                              M        /image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506.jpg
CH1506                                              L        /1/image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506_3_.jpg
CH1506                                              XL       /1/image/1000x1500/9df78eab33525d08d6e5fb8d27136e95/c/h/ch1506_4_.jpg
CH1506                                              2X  
CH1506                                              3X                                          

(抱歉,无法使此处的文本正确对齐。)

通过几个简单的查询,您可以保持偶数顺序:

={Original!A1:F1; ARRAYFORMULA({ARRAY_CONSTRAIN(SORT(IF(ISERROR(VALUE(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0))), (QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0), 
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)), IF(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)<>"", VALUE(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0), 
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)), )), 1, 1), 999^99, 4),
 QUERY(TO_TEXT(SORT(IF(ISERROR(VALUE(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0), 
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0))), (QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0), 
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)), IF(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)<>"", VALUE(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)), )), 1, 1, 5, 1)), "select Col5", 0),
 QUERY(SORT(IF(ISERROR(VALUE(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0))), (QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0), 
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)), IF(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)<>"", VALUE(QUERY({
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0), 
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0)), )), 1, 1), "select Col6", 0)})}

如果您不需要保留订单,请执行此操作:

={Original!A1:F1; ARRAYFORMULA(QUERY({ 
 QUERY(TO_TEXT(Original!A2:D), "order by Col1", 0),
 QUERY(TO_TEXT(Original!A2:E), "select Col5 order by Col1,Col5 desc", 0),
 QUERY(TO_TEXT(Original!A2:F), "select Col6 order by Col1,Col6 desc", 0)},
 "where Col5 is not null or Col6 is not null", 0))}

={"uniqueID", "DressTitle", "dressDescription", "dressTags", "Size", "DressImgs"; 
 ARRAYFORMULA(QUERY(REGEXREPLACE({
 QUERY(SORT(IF(LEN(A2:A), {IF(ISERR(VALUE(A2:A)), A2:A, VALUE(A2:A)), 
 IF(B2:D="", A2:A&"♠", A2:A&"♦"&B2:D)}, ), 1, 1), "select *"),
 QUERY(SORT(IF(LEN(A2:A), {IF(ISERR(VALUE(A2:A)), A2:A, VALUE(A2:A)), E2:E, 
 IF(E2:E="", A2:A&"♠", A2:A&"♦"&E2:E)}, ), 1, 1, 2, 1), "select Col3"),
 QUERY(SORT(IF(LEN(A2:A), {IF(ISERR(VALUE(A2:A)), A2:A, VALUE(A2:A)), F2:F, 
 IF(F2:F="", A2:A&"♠", A2:A&"♦"&F2:F)}, ), 1, 1, 2, 1), "select Col3")},
 "(.*)♠|(.*)♦", ""), "where Col5 is not null or Col6 is not null"))}