在Google表格中使用CHOOSE和CONCATENATE与ARRAYFORMULA [英] Using CHOOSE and CONCATENATE with ARRAYFORMULA in Google Sheets

查看:152
本文介绍了在Google表格中使用CHOOSE和CONCATENATE与ARRAYFORMULA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在一列中创建一个日期数组,我用ARRAYFORUMULA的CHOOSE和CONCATENATE公式遇到了麻烦。有没有办法解决以下问题:



列I包含日期;第一次约会落在Weds上;所有其他日期都是星期一



当我使用


= CONCATENATE(ARRAYFORMULA(Text($ I9:$ I12) ((文本($ I9:$ I14,ddd)),111))
= ARRAYFORMULA(CONCATENATE((()),111)
= ARRAYFORMULA(CONCATENATE ARRAYFORMULA(文本($ I9:$ I14,ddd))),111))


获得以下单元格响应:

WedMonMonMon111



我想要得到的是:

周三111

周一111

周一111 >
Mon 111



当我使用以下等式:

  = ARRAYFORMULA(选择(工作日(I10:I14),1 Sun,2 Mon,3 Tue,4 Wed,5 Thursday,6 Fri,7 (星期几(ARRAYFORMULA(I10:I14))),1太阳,2星期一,3星期二,4星期三,星期六 (星期一(I10:I14)),1星期日,2星期一,星期四,星期五,星期六))

= ARRAYFORMULA 3星期三,4星期三,5星期四,6星期五,7星期六))

= ARRAYFORMULA(选择(星期几(ARRAYFOR MULA(I10:I14)),1 Sun,2 Mon,3 Tue,4 Wed,5 Thursday,6 Fri,7 Sat)) code>

我得到以下单元格响应:

2 Mon



我想要得到的是
1星期一

2星期一

2星期一

2星期一

2星期一



我可以使用以下公式得到上面列出的日期格式:

= ARRAYFORMULA(weekday(I9:I14)& & Text(I9:I14,ddd))



但我想知道是否有办法使用CHOOSE和CONCATENATE函数ARRAYFORUMULA。有没有人知道这件事?

解决方案


但我想知道是否有一种方法可以使用CHOICE和
CONCATENATE函数与ARRAYFORUMULA。

不符合你想使用它们的方式,并且原因不同。

CONCATENATE是一个聚合函数(如SUM,AVERAGE等),它会吞噬并处理括号内的所有内容。换句话说,它不能在数组上迭代。解决方案是使用& 运算符(而不是您的最终公式)。



选择有点奇怪;无论出于何种原因,在最新版本的Google表格中,Google员工都已经移除了在第一个参数中迭代数组的能力。您列出的所有CHOOSE示例将在旧版本中用作数组公式(尽管您只需要一个ArrayFormula函数)。



对于您的具体示例,我认为您的最终的配方是最好的。但是,如果您想复制以下效果:

= ArrayFormula(CHOOSE(range,element 1,element 2,. ...))



您可以使用这种看起来奇怪的解决方法:

= ArrayFormula(HLOOKUP(element 1,{element 1;element 2; ...},range,0))


I was trying to create an array of dates in a column, and I ran into trouble using the CHOOSE and CONCATENATE formulas with ARRAYFORUMULA. Is there a way to solve the following problems:

Column I contains dates; the first date falls on a Weds; all of the other dates fall on a Monday

When I use
=CONCATENATE(ARRAYFORMULA(Text($I9:$I12,"ddd")),"111") =ARRAYFORMULA(CONCATENATE((Text($I9:$I14,"ddd")),"111")) =ARRAYFORMULA(CONCATENATE((ARRAYFORMULA(Text($I9:$I14,"ddd"))),"111"))

I get the following single-cell response:
WedMonMonMon111

What I am trying to get is:
Wed 111
Mon 111
Mon 111
Mon 111

When I use the following equations:

=ARRAYFORMULA(CHOOSE( weekday(I10:I14), "1 Sun", "2 Mon", "3 Tue", "4 Wed", "5 Thurs", "6 Fri", "7 Sat"))

=ARRAYFORMULA(CHOOSE(ARRAYFORMULA(weekday(ARRAYFORMULA(I10:I14))), "1 Sun", "2 Mon", "3 Tue", "4 Wed", "5 Thurs", "6 Fri", "7 Sat"))

=ARRAYFORMULA(CHOOSE( ARRAYFORMULA(weekday(I10:I14)), "1 Sun", "2 Mon", "3 Tue", "4 Wed", "5 Thurs", "6 Fri", "7 Sat"))

=ARRAYFORMULA(CHOOSE(weekday(ARRAYFORMULA(I10:I14)), "1 Sun", "2 Mon", "3 Tue", "4 Wed", "5 Thurs", "6 Fri", "7 Sat"))

I get the following single-cell response:
2 Mon

What I am trying to get is 1 Wed
2 Mon
2 Mon
2 Mon
2 Mon

I can get the date format listed above using the following equation:
=ARRAYFORMULA(weekday(I9:I14)& " "&Text(I9:I14, "ddd"))

But I was wondering if there was a way to use the CHOOSE and CONCATENATE functions with ARRAYFORUMULA. Does anyone know anything about this?

解决方案

But I was wondering if there was a way to use the CHOOSE and CONCATENATE functions with ARRAYFORUMULA.

Not in the way you want to use them, and for different reasons.

CONCATENATE is an "aggregating" function (like SUM, AVERAGE etc) that will "gobble up" and process everything within the parentheses. In other words, it can't be iterated over an array. The solution is to use the & operator instead (as you have done in your final formula).

CHOOSE is a bit strange; for whatever reason, in the newest version of Sheets, the Googlers have removed the ability for it to be iterated over an array in the first argument. All of those CHOOSE examples you listed will work as an array formula in the old version (although you only need one ArrayFormula function).

For your specific example, I think your final formula is best. But if you wanted to replicate the expected effect of:

=ArrayFormula(CHOOSE(range,"element 1","element 2",...))

you could use this odd-looking workaround:

=ArrayFormula(HLOOKUP("element 1",{"element 1";"element 2";...},range,0))

这篇关于在Google表格中使用CHOOSE和CONCATENATE与ARRAYFORMULA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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