[英]Using Google Sheets ARRAYFORMULA to Concatenate Series of Item Based from Lowest to Highest Values per Row
I have a table with three Columns: Column A: name of Item, Column B: Lowest value of series, Column C: the Highest value of series.我有一个包含三列的表格:A 列:项目名称,B 列:系列的最低值,C 列:系列的最高值。 enter image description here
在此处输入图像描述
What I want to achieve is:我想要实现的是:
So Apple 7 9 will yield: "Apple_7", "Apple_8", "Apple_9"所以 Apple 7 9 将产生:“Apple_7”、“Apple_8”、“Apple_9”
Concatenate/Join such sequence per row into Column D So将每行的此类序列连接/加入 D 列 So
Item![]() |
From![]() |
Until![]() |
Result![]() |
---|---|---|---|
Apple![]() |
7 ![]() |
9 ![]() |
"Apple_7, Apple_8, Apple_9" ![]() |
Berry![]() |
3 ![]() |
8 ![]() |
"Berry_3, Berry_4, Berry_5, Berry_6, Berry_7, Berry_8" ![]() |
Doing it all using one Arrayformula, so that new row added can be automatically calculated.使用一个 Arrayformula 完成所有操作,以便可以自动计算添加的新行。
Here is example sheet: https://docs.google.com/spreadsheets/d/1R5raKmmt5-aOIorAZGHjv_-fdySKWjCMB_FRQwm1vag/edit#gid=0这是示例表: https://docs.google.com/spreadsheets/d/1R5raKmmt5-aOIorAZGHjv_-fdySKWjCMB_FRQwm1vag/edit#gid=0
I tried in Column D:我在 D 列中尝试过:
arrayformula(textjoin(", ",true,arrayformula(A3:A&"_"&sequence(1,C3:C-B3:B+1,B3:B,1))))
Apparently, the sequence function only take value from Column B and join it in first row.显然,序列 function 仅从 B 列获取值并将其加入第一行。
Any help will be appreciated.任何帮助将不胜感激。
Try below BYROW()
formula (see your file, harun24hr sheet).试试下面
BYROW()
公式(见你的文件,harun24hr 表)。
=BYROW(A3:INDEX(A3:A,COUNTA(A3:A)),LAMBDA(x,TEXTJOIN(";",1,INDEX(x&"_"& SEQUENCE(INDEX(C:C,ROW(x))-INDEX(B:B,ROW(x))+1,1,INDEX(B:B,ROW(x)))))))
Here A3:INDEX(A3:A,COUNTA(A3:A))
will return a array of values as well cell reference from A3 to last non empty cell in column A (Assume you do not have any blank rows inside data).这里
A3:INDEX(A3:A,COUNTA(A3:A))
将返回一个值数组以及从A3到 A 列中最后一个非空单元格的单元格引用(假设数据中没有任何空白行)。 If you have blank row, then you have to use different approach.如果你有空行,那么你必须使用不同的方法。 See this post by @TheMaster
请参阅@TheMaster 的这篇文章
Then LAMBDA()
will apply TEXTJOIN() and SEQUENCE() function for each cell of B as well as C column .然后
LAMBDA()
将对B 的每个单元格以及 C 列应用TEXTJOIN()和SEQUENCE() function。
SEQUENCE()
will make series from start to end number and by concatenating A column and will generate your desired strings. SEQUENCE()
将从开始到结束编号并通过连接 A 列来制作系列,并将生成您想要的字符串。
Finally TEXTJOIN()
will join all those strings with delimiter to a single cell.最后
TEXTJOIN()
会将所有带有分隔符的字符串连接到一个单元格中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.