ARRAYFORMULA()不适用于SPLIT() [英] ARRAYFORMULA() does not work with SPLIT()

查看:103
本文介绍了ARRAYFORMULA()不适用于SPLIT()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么当我使用 = arrayformula(split(input!G2:G,,))时,分割公式不会扩展到整个列上?

我只对输入!G2单元格得到结果,但是对G列没有其他结果。其他公式如 = arrayformula(find(,,input!G2:G))似乎可以正常工作并且可以毫无问题地扩展。

解决方案

现在,应用于垂直数组的SPLIT可以工作。 (2017年1月4日)


$ b

= ArrayFormula(SPLIT(input!G2:G,,)) $ b

或用于掩蔽错误
$ b

= ArrayFormula(IFERROR(SPLIT(输入!G2:G,,)))



注意:结果数组的宽度与SPLITted元素的最大数量一样宽。




(答案的其余部分不再适用,但保留用于......历史目的?)



这将被视为一个非常糟糕的答案,但它只是没有。



我怀疑这可能是因为它可能会产生一个锯齿状的数组(每行不同数量的元素),这可能被认为是有问题的。然而,在之前版本的Sheets中,array SPLIT用于工作(尽管存在一个错误,它在数组的第一个元素上无法正常工作)。



SPLIT不是一个单独的函数,不能在数组上迭代(例如INDIRECT,INDEX,SUMIFS)。




解决方法(2017年1月4日编辑):

= ArrayFormula(REGEXREPLACE(input!G2:G& REPT( 6),REPT( ([^,] *),,6)及 *, $ &安培;柱(OFFSET(A1 ,,, 1,6))))

OFFSET(A1 ,,, 1,6)中的6和REPT函数决定了SPLIT中元素的最大数量。你可以注入一个表达式来计算数据列中元素的最大数量,但是性能会更糟糕。



另外,这里需要注意的是它将只支持单个字符的分割(本例中为逗号)。



或者,您可以查看Google Apps脚本自定义功能。






这个以前的解决方法不再有效,因为REGEXEXTRACT不再支持第二个参数的数组 - 因为它在2017年1月仍然如此。


$ b

= ArrayFormula(IFERROR(REGEXEXTRACT(,& input!G2:G,^& REPT(,+ ^,] +,COLUMN(OFFSET(A1 ,,, 1,6)) - 1)&,+([^,] +))))


Why doesn't the split formula get expanded over the entire column when I use =arrayformula(split(input!G2:G, ",")) ?

I get result only for the input!G2 cell, but not the rest in the G column. Other formulas like =arrayformula(find(",", input!G2:G)) seem to function and get expanded without problems.

解决方案

SPLIT applied to a vertical array does, now, work. (Jan 4 2017)

=ArrayFormula(SPLIT(input!G2:G,","))

or for error masking

=ArrayFormula(IFERROR(SPLIT(input!G2:G,",")))

Note: the resultant array is as wide as the maximum number of SPLITted elements.


(The remainder of the answer no longer applies, but retained for... historical purposes?)

This will be regarded as a really bad answer, but: it just doesn't.

I suspect it might be because it potentially will produce a jagged array (different number of elements in each row), which may be considered problematic. However, an "array SPLIT" used to "work" in the previous version of Sheets (albeit with a bug where it didn't work properly on the first element of the array).

SPLIT is not alone as a function that can't be iterated over an array (eg INDIRECT, INDEX, SUMIFS).


A workaround (edited Jan 4 2017):

=ArrayFormula(REGEXREPLACE(input!G2:G&REPT(",",6),REPT("([^,]*),",6)&",*","$"&COLUMN(OFFSET(A1,,,1,6))))

The 6 in the OFFSET(A1,,,1,6) and the REPT functions determines the maximum number of elements in the SPLIT. You could inject an expression that would calculate the maximum number of elements from the column of data, but then performance would suffer even more.

Also, a caveat here is that it will only support splitting by a single character (in this case a comma).

Alternatively, you could look at a Google Apps Script custom function.


This previous workaround no longer works, as REGEXEXTRACT no longer appears to support an array for the second argument - as it stands in January 2017, anyway.

=ArrayFormula(IFERROR(REGEXEXTRACT(","&input!G2:G,"^"&REPT(",+[^,]+",COLUMN(OFFSET(A1,,,1,6))-1)&",+([^,]+)")))

这篇关于ARRAYFORMULA()不适用于SPLIT()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆