Google表格通过分割逗号分隔的多个值来复制行

发布于 2025-01-12 10:01:35 字数 1063 浏览 0 评论 0原文

我在 Google 表格中有数据,其中单列中提到了多个日期。我想分隔每个日期,并且每个日期应重复同一行。

我将不胜感激你的帮助。

尝试这样做,但它不起作用。

=ARRAYFORMULA({"DATE","EMPLOYEE NAME";QUERY(IFERROR(SPLIT(FLATTEN(IFERROR(Sheet1!A:D
&CHAR(9999)&SPLIT(Sheet1!H:H,","),)),CHAR(9999)),),
"SELECT Col2, Col1 WHERE Col2 IS NOT NULL ORDER BY Col2 ASC",0)})

工作表链接

我尝试过此操作,但它没有拆分日期。

function result(range) {
  delimiter = ","
  targetColumn = 8

  var output2 = [];
  for(var i=0, iLen=range.length; i<iLen; i++) {
    var s = range[i][targetColumn].split(delimiter);    
    for(var j=0, jLen=s.length; j<jLen; j++) {
      var output1 = []; 
      for(var k=0, kLen=range[0].length; k<kLen; k++) {
        if(k == targetColumn) {
          output1.push(s[j]);
        } else {
          output1.push(range[i][k]);
        }
      }
      output2.push(output1);
    }    
  }
  return output2;
}

I have Data in Google Sheets Where multiple Dates are mentioned in single column. I want to separate the Each date and same row should be repeated for each date.

I would appreciate your help.

Trying with this but its not working.

=ARRAYFORMULA({"DATE","EMPLOYEE NAME";QUERY(IFERROR(SPLIT(FLATTEN(IFERROR(Sheet1!A:D
&CHAR(9999)&SPLIT(Sheet1!H:H,","),)),CHAR(9999)),),
"SELECT Col2, Col1 WHERE Col2 IS NOT NULL ORDER BY Col2 ASC",0)})

Sheet Link

I tried with this but its not spliting the dates.

function result(range) {
  delimiter = ","
  targetColumn = 8

  var output2 = [];
  for(var i=0, iLen=range.length; i<iLen; i++) {
    var s = range[i][targetColumn].split(delimiter);    
    for(var j=0, jLen=s.length; j<jLen; j++) {
      var output1 = []; 
      for(var k=0, kLen=range[0].length; k<kLen; k++) {
        if(k == targetColumn) {
          output1.push(s[j]);
        } else {
          output1.push(range[i][k]);
        }
      }
      output2.push(output1);
    }    
  }
  return output2;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哆啦不做梦 2025-01-19 10:01:35

continue

try:

=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(
 A2:A11&"×"&B2:B11&"×"&C2:C11&"×"&D2:D11&"×"&E2:E11&"×"&F2:F11&"×"&G2:G11&"×"&
 TRIM(SPLIT(H2:H11, ","))&"×"&I2:I11&"×"&J2:J11&"×"&K2:K11), "×", 0, 0), 
 "where Col8 is not null"))

enter image description here


update:

=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(FLATTEN(FLATTEN(
 A2:A11&"×"&B2:B11&"×"&C2:C11&"×"&D2:D11&"×"&E2:E11&"×"&F2:F11&"×"&G2:G11&"×"&
 TRIM(SPLIT(H2:H11, ",")))&"×"&TRANSPOSE(QUERY(FLATTEN(TRIM(SPLIT(I2:I11, ","))), 
 "where Col1 is not null", )))&"×"&TRANSPOSE(QUERY(FLATTEN(TRIM(SPLIT(J2:J11, ","))), 
 "where Col1 is not null", ))), "×", 0, 0), "where Col8 is not null", ))

or:

=ARRAYFORMULA(UNIQUE(QUERY(SPLIT(FLATTEN(FLATTEN(FLATTEN(
 A2:A11&"×"&B2:B11&"×"&C2:C11&"×"&D2:D11&"×"&E2:E11&"×"&F2:F11&"×"&G2:G11&"×"&
 TRIM(SPLIT(H2:H11, ",")))&"×"&TRANSPOSE(QUERY(FLATTEN(TRIM(SPLIT(I2:I11, ","))), 
 "where Col1 is not null", )))&"×"&TRANSPOSE(QUERY(FLATTEN(TRIM(SPLIT(J2:J11, ","))), 
 "where Col1 is not null", ))), "×", 0, 0), "where Col8 is not null", )))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文