将一列行号转换成单元格列表,并在Google表格中对它们应用公式。

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

Convert a list of rownumbers to a list of cells and apply a formula to them in Google Sheets

问题

我有一个数字列表,位于 A 列的不同行号对应的 B 列(例如,在 B1,我有列表 {1,2,3})。
我想把这个列表转换为单元格列表({A1,A2,A3}),并在 C 列应用一个公式(例如,我想要对它们进行 AND 运算)。

A 列始终包含布尔值。
B 列始终包含由逗号分隔的有效行号。
我想要一个可以放在 C 列并向下拖动以提取数字的公式(例如使用 =SPLIT(B1,",")),然后对其应用公式。

下表显示了我想要实现的示例。请注意,C 列包含了手动输入方法,我希望避免使用。

      | 列 A     | 列 B   | 列 C           | 列 D(期望输出)
      | -------- | ------ | -------------- | -----------
行 1  | TRUE     | 1,2,3  | =AND(A1,A2,A3) | FALSE
行 2  | FALSE    | 2,4    |                | FALSE
行 3  | FALSE    | 4,6,2,1|               | FALSE
行 4  | FALSE    | 2      |                | FALSE
行 5  | TRUE     | 1,5    |                | TRUE
行 6  | FALSE    | 1,5,3  |                | FALSE

一些我尝试过的方法包括使用:

=INDEX(A:A, SPLIT(B1,","), 1)

=AND(ARRAYFORMULA(INDEX(A:A, SPLIT(B1,","), 1)))

我还尝试过改变上述方程中的公式顺序,但都无济于事。

我只成功让我的公式受到 B 列中第一个行号的影响。

英文:

I have a list of numbers in Column B corresponding to different rownumbers in Column A (for example, in B1, I have the list {1,2,3}).
I would like to turn this list into a list of cells ({A1,A2,A3}) and apply a formula to that list in Column C (for example, I would like to AND them together).

Column A always contains Boolean Values.
Column B will always contain valid rownumbers separated by a comma.
I would like a formula that I can put in Column C and drag down and extract the numbers from (for example using =SPLIT(B1,",")) and then apply a formula to.

Shown in the table below is a sample of what I would like to achieve. Note that Column C contains a manual entry approach that I would like to avoid.

      | Column A | Column B | Column C       | Column D (expected ouput)
      | -------- | -------- | -------------- | -----------
Row 1 | TRUE     | 1,2,3    | =AND(A1,A2,A3) | FALSE
Row 2 | FALSE    | 2,4      |                | FALSE
Row 3 | FALSE    | 4,6,2,1  |                | FALSE
Row 4 | FALSE    | 2        |                | FALSE
Row 5 | TRUE     | 1,5      |                | TRUE
Row 6 | FALSE    | 1,5,3    |                | FALSE

Some things I have tried include using

=INDEX(A:A,SPLIT(B1,","),1)

=AND(ARRAYFORMULA(INDEX(A:A,SPLIT(B1,","),1)))

I have also tried moving around the order of the formulas in the above equation to no avail.

I have only managed to get my formula to be affected by the first rownumber in column B.

答案1

得分: 0

你很接近了!使用 BYCOL(考虑到 SPLIT 结果是一系列列中的单元格),你可以获取 A 列的 INDEX;并将其包裹在 AND 函数中:

    =AND(BYCOL(SPLIT(B1,";"),LAMBDA(i,INDEX(A:A,i))))

如果你想的话,可以使用 BYROW 将其包裹,以应用到你的整个范围:

    =BYROW(B:B,LAMBDA(b,IF(b="","",AND(BYCOL(SPLIT(b,";"),LAMBDA(i,INDEX(A:A,i)))))))
英文:

You were very close! With BYCOL (considering that the SPLIT result is a serie of cells in columns) you can get the INDEX of column A; and wrap it in AND:

=AND(BYCOL(SPLIT(B1,","),LAMBDA(i,INDEX(A:A,i))

If you want, you can wrap it in BYROW to apply to your whole range:

=BYROW(B:B,LAMBDA(b,IF(b="","",AND(BYCOL(SPLIT(b,","),LAMBDA(i,INDEX(A:A,i)))))))

将一列行号转换成单元格列表,并在Google表格中对它们应用公式。

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

发表评论

匿名网友

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

确定