为什么我的 ArrayFormula 出错?我该如何纠正它? (我不是在寻找另一个 Arrayformula 作为解决方案!)
Why my ArrayFormula is giving error? How do I correct it? (I'm not looking for another Arrayformula as solutions!)
我想要 C1 的 ArrayFormula,它给出所需的结果,如图所示。
条目sheet:
(C列是我必填的列)
输入日期是为名称分配组的日期,即 a、b、c、d、e、f
条件:
- count 的值完全基于输入的日期(如果 john 在最低日期(10-Jun)被分配 a 则计数值为 1,如果 rose 被分配a 在第二个最低日期(6 月 17 日)然后计数值为 2)。
- 即使以任何方式对数据进行排序,count 的值也不会改变,因为 Date Entered 列值始终是永久的并且不会改变。
- 新条目日期可以是任何日期,不一定是最高日期(如果名称为 Rydu 的新条目在 6 月 9 日分配 a 那么它的计数值将变为 1,然后 john's (10-Jun) 将变成 2 等等)
示例:
在我以任意随机顺序对数据进行排序后,这样说:
随机排序sheet:
(计数值保持不变)
当我在(第 4 行和第 14 行)之间和最后一行(第 17 行)之后执行新条目时:
随机排序sheet:
(不管我在哪里)
我已经得到一个 ArrayFormula,它给出了所需的结果:
={"AF Formula1"; ArrayFormula(IF(B2:B="", "", COUNTIFS(B:B, "="&B2:B, D:D, <"&D2:D)+1))}
我不是在寻找另一个 Arrayformula 作为解决方案。 我想知道我的ArrayFormula有什么问题?我该如何更正它?
我试图计算自己的 ArrayFormula,但它不起作用:
我得到了每个单元格的公式:
=RANK($D2,FILTER($D:$D, $B:$B=$B2),1)
我发现 Filter 不适用于 ArrayFormula,所以我不得不采取不同的方法。
我从以前的 question answer (Arrayformula at H3) which was similar since in both cases each cell FILTER formula returns more than 1 value. (It was actually answered by player0)
那里得到了帮助
使用相同的技术,我想出了这个非常有效的公式:
=RANK($D2, ARRAYFORMULA(TRANSPOSE(SPLIT(VLOOKUP($B2, SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({$B:$B&"×", $D:$D}, "SELECT MAX(Col2) WHERE Col2 IS NOT NULL GROUP BY Col2 PIVOT Col1", 1),, 9^9)), "×")), " ", ","), 2, 0), ","))), 1)
现在,当我尝试将其转换为 ArrayFormula 时:
($D2 到 $D2:$D & $B2 到 $B2:$B)
=ARRAYFORMULA(RANK($D2:$D,TRANSPOSE(SPLIT(VLOOKUP($B2:$B, SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({$B:$B&"×", $D:$D}, "SELECT MAX(Col2) WHERE Col2 IS NOT NULL GROUP BY Col2 PIVOT Col1", 1),, 9^9)), "×")), " ", ","), 2, 0), ",")), 1))
它给我一个错误“在 VLOOKUP 评估中没有找到值”,当我将 $B2 更改为 $B2:$B[= 时,我发现问题只出现在 VLOOKUP 中93=].
我确定 VLOOKUP 可以与 ArrayFormula 一起使用,但我不明白我的公式哪里出了问题!请帮我更正我的 ArrayFormula。
我已经在您共享的 sheet 名为“我的实践”的选项卡上回答了您:
您不能像在单元格 CI2 中那样拆分两列数组。这就是为什么你的公式不起作用。您只能拆分一列数组。
我知道您正在努力学习,但恐怕尝试使用像这样复杂的公式会使学习变得更难。
如果我理解正确,您正试图根据 D 列日期对 B 列进行“排序”,使得日期按理论上的升序排列,因此如果您随机化数据集,则每个条目的“排序”将保持不变相同,不会根据您引入的随机性而改变。
因此正确的公式是:
={"fx"; INDEX(IFNA(VLOOKUP(B2:B&D2:D,
{INDEX(SORT({B2:B&D2:D, D2:D}, 2, 1),,1),
IFERROR(1/(1/COUNTIFS(
INDEX(SORT(B2:D, 3, 1),,1),
INDEX(SORT(B2:D, 3, 1),,1), ROW(B2:B), "<="&ROW(B2:B))))}, 2, 0)))}
{"fx"; ...}
array of 2 tables (header & actual table) under each other eg. ;
outer shorter INDEX
or longer ARRAYFORMULA
(doesnt matter which one) is needed coz we are processing an array
IFNA
for removing possible #N/A
errors from VLOOKUP
function when VLOOKUP
fails to find a match
we VLOOKUP
joint B and D column B2:B&D2:D
in our virtual table {}
and returning second 2
column if there is an exact match 0
our virtual table {INDEX(SORT({B2:B&D2:D, D2:D}, 2, 1),,1), ...}
we VLOOKUP
from is constructed with 2 columns next to each other eg. ,
we are getting the first column by creating an array of 2 columns {B2:B&D2:D, D2:D}
next to each other where we SORT
this array by date/2nd column 2
, in ascending order 1
but all we need after sorting is the 1st column so we use INDEX
where we bring all rows ,,
and the first column 1
now lets take a look on how we getting the 2nd column of our virtual table by using COUNTIFS
which will mimic the "rank"
IFERROR(1/(1/
is used to remove all zero values from the output (all empty rows would have 0 in it as the "rank")
under COUNTIFS
we put 2 pairs of arguments: "if column is qual to column" and "if row is larger or equal to next row increment it by 1" ROW(B2:B), "<="&ROW(B2:B))
for "if column is qual to column" we do this twice and use range B2:D
and sort it by date/3rd column 3
in ascending order 1
and of this we again need only the 1st column so we INDEX
it and return all rows ,,
and first column 1
使用这个公式,您可以添加、删除或随机化您的数据集,您将始终获得每一行的正确值
至于为什么你的公式不起作用...为了不得到 vlookup 的 #N/A 错误,你需要定义范围的结束行,但结果仍然不会像你期望的那样,因为公式不适合这份工作。
如前所述,有些功能在 AF 下不受支持,例如 SUM
、AND
、OR
,还有一些功能可以工作,但方式不同,例如 IFS
或有一些限制,例如 SPLIT
、GOOGLEFINANCE
等
我想要 C1 的 ArrayFormula,它给出所需的结果,如图所示。
条目sheet:
(C列是我必填的列)
输入日期是为名称分配组的日期,即 a、b、c、d、e、f
条件:
- count 的值完全基于输入的日期(如果 john 在最低日期(10-Jun)被分配 a 则计数值为 1,如果 rose 被分配a 在第二个最低日期(6 月 17 日)然后计数值为 2)。
- 即使以任何方式对数据进行排序,count 的值也不会改变,因为 Date Entered 列值始终是永久的并且不会改变。
- 新条目日期可以是任何日期,不一定是最高日期(如果名称为 Rydu 的新条目在 6 月 9 日分配 a 那么它的计数值将变为 1,然后 john's (10-Jun) 将变成 2 等等)
示例:
在我以任意随机顺序对数据进行排序后,这样说:
随机排序sheet:
(计数值保持不变)
当我在(第 4 行和第 14 行)之间和最后一行(第 17 行)之后执行新条目时:
随机排序sheet:
(不管我在哪里)
我已经得到一个 ArrayFormula,它给出了所需的结果:
={"AF Formula1"; ArrayFormula(IF(B2:B="", "", COUNTIFS(B:B, "="&B2:B, D:D, <"&D2:D)+1))}
我不是在寻找另一个 Arrayformula 作为解决方案。 我想知道我的ArrayFormula有什么问题?我该如何更正它?
我试图计算自己的 ArrayFormula,但它不起作用:
我得到了每个单元格的公式:
=RANK($D2,FILTER($D:$D, $B:$B=$B2),1)
我发现 Filter 不适用于 ArrayFormula,所以我不得不采取不同的方法。
我从以前的 question answer (Arrayformula at H3) which was similar since in both cases each cell FILTER formula returns more than 1 value. (It was actually answered by player0)
那里得到了帮助使用相同的技术,我想出了这个非常有效的公式:
=RANK($D2, ARRAYFORMULA(TRANSPOSE(SPLIT(VLOOKUP($B2, SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({$B:$B&"×", $D:$D}, "SELECT MAX(Col2) WHERE Col2 IS NOT NULL GROUP BY Col2 PIVOT Col1", 1),, 9^9)), "×")), " ", ","), 2, 0), ","))), 1)
现在,当我尝试将其转换为 ArrayFormula 时: ($D2 到 $D2:$D & $B2 到 $B2:$B)
=ARRAYFORMULA(RANK($D2:$D,TRANSPOSE(SPLIT(VLOOKUP($B2:$B, SUBSTITUTE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({$B:$B&"×", $D:$D}, "SELECT MAX(Col2) WHERE Col2 IS NOT NULL GROUP BY Col2 PIVOT Col1", 1),, 9^9)), "×")), " ", ","), 2, 0), ",")), 1))
它给我一个错误“在 VLOOKUP 评估中没有找到值”,当我将 $B2 更改为 $B2:$B[= 时,我发现问题只出现在 VLOOKUP 中93=].
我确定 VLOOKUP 可以与 ArrayFormula 一起使用,但我不明白我的公式哪里出了问题!请帮我更正我的 ArrayFormula。
我已经在您共享的 sheet 名为“我的实践”的选项卡上回答了您:
您不能像在单元格 CI2 中那样拆分两列数组。这就是为什么你的公式不起作用。您只能拆分一列数组。
我知道您正在努力学习,但恐怕尝试使用像这样复杂的公式会使学习变得更难。
如果我理解正确,您正试图根据 D 列日期对 B 列进行“排序”,使得日期按理论上的升序排列,因此如果您随机化数据集,则每个条目的“排序”将保持不变相同,不会根据您引入的随机性而改变。
因此正确的公式是:
={"fx"; INDEX(IFNA(VLOOKUP(B2:B&D2:D,
{INDEX(SORT({B2:B&D2:D, D2:D}, 2, 1),,1),
IFERROR(1/(1/COUNTIFS(
INDEX(SORT(B2:D, 3, 1),,1),
INDEX(SORT(B2:D, 3, 1),,1), ROW(B2:B), "<="&ROW(B2:B))))}, 2, 0)))}
{"fx"; ...}
array of 2 tables (header & actual table) under each other eg.;
outer shorter
INDEX
or longerARRAYFORMULA
(doesnt matter which one) is needed coz we are processing an array
IFNA
for removing possible#N/A
errors fromVLOOKUP
function whenVLOOKUP
fails to find a match
we
VLOOKUP
joint B and D columnB2:B&D2:D
in our virtual table{}
and returning second2
column if there is an exact match0
our virtual table
{INDEX(SORT({B2:B&D2:D, D2:D}, 2, 1),,1), ...}
weVLOOKUP
from is constructed with 2 columns next to each other eg.,
we are getting the first column by creating an array of 2 columns
{B2:B&D2:D, D2:D}
next to each other where weSORT
this array by date/2nd column2
, in ascending order1
but all we need after sorting is the 1st column so we useINDEX
where we bring all rows,,
and the first column1
now lets take a look on how we getting the 2nd column of our virtual table by using
COUNTIFS
which will mimic the "rank"
IFERROR(1/(1/
is used to remove all zero values from the output (all empty rows would have 0 in it as the "rank")
under
COUNTIFS
we put 2 pairs of arguments: "if column is qual to column" and "if row is larger or equal to next row increment it by 1"ROW(B2:B), "<="&ROW(B2:B))
for "if column is qual to column" we do this twice and use range
B2:D
and sort it by date/3rd column3
in ascending order1
and of this we again need only the 1st column so weINDEX
it and return all rows,,
and first column1
使用这个公式,您可以添加、删除或随机化您的数据集,您将始终获得每一行的正确值
至于为什么你的公式不起作用...为了不得到 vlookup 的 #N/A 错误,你需要定义范围的结束行,但结果仍然不会像你期望的那样,因为公式不适合这份工作。
如前所述,有些功能在 AF 下不受支持,例如 SUM
、AND
、OR
,还有一些功能可以工作,但方式不同,例如 IFS
或有一些限制,例如 SPLIT
、GOOGLEFINANCE
等