是的,我閱讀:Excel:矩陣公式 - 為什麼不回傳矩陣(向量)?但這不一樣。
基本上我不明白為什麼公式是這樣的:{=MATCH({1,2,3},{1,2,3},0)}
它通常會返回矩陣(向量){1,2,3}
返回單一值。
考慮這個例子:
注意:有很長的介紹 - 一個有趣的部分從粗體文本下方開始:“到目前為止,一切都按預期進行。”
有一個帶有Name
和 Revision 的表columns
。
- 我想為每個唯一的 Name 提供一個唯一的整數
GroupNo
。 - 然後根據修正值加上
GroupNo
小數部分( )RevPart
""=0, "a"=0.01, ...
GroupNo+RevPart
叫做FullGroupNo
(FGN
)- 我想知道
FGN
每個名稱組的最大值:(MaxInGroup
)MIG
使用表格 ( Table1
) 中的多個欄位可以輕鬆完成此操作:
GroupNo: =MATCH([@Name],[Name],0)
RevPart: =INDEX({0,1},MATCH([@Revision],{"","a"},0))/100
FullGroupNo: =[@GroupNo]+[@RevPart]
MaxInGroup: {=MAX(([@GroupNo]=[GroupNo])*[FullGroupNo])}
Table1
+------+----------+---------+---------+-------------+------------+
| Name | Revision | GroupNo | RevPart | FullGroupNo | MaxInGroup |
+------+----------+---------+---------+-------------+------------+
| A | ="" | 1 | 0 | 1 | 1,01 |
| A | a | 1 | 0,01 | 1,01 | 1,01 |
| B | ="" | 3 | 0 | 3 | 3 |
| C | ="" | 4 | 0 | 4 | 4,01 |
| C | a | 4 | 0,01 | 4,01 | 4,01 |
+------+----------+---------+---------+-------------+------------+
Note: ="" means there is a blank string in the cell (formula ="")
( FullGroupNo
)FGN
可以透過僅引用Name
和Revision
列的一個公式來獲得。
FGN_2: {=(INDEX({0,1},MATCH([@Revision],{"","a"},0))/100+MATCH([@Name],[Name],0))}
FGN_2 is a new column in the table (Table1) above. It's matrix formula returns single (not-matrix) value.
Area under FGN (Matrix) is an ordinary worksheet range. This whole area contains return (matrix) value.
FGN (Matrix): {=INDEX({0,1},MATCH(Table1[Revision],"","a"},0))/100+MATCH(Table1[Name],Table1[Name],0))}
Table1 Just range
+-------+ +--------------+
| FGN_2 | | FGN (Matrix) |
+-------+ +--------------+
| 1 | | 1 |
| 1,01 | | 1,01 |
| 3 | | 3 |
| 4 | | 4 |
| 4,01 | | 4,01 |
+-------+ +--------------+
現在我嘗試將其合併MaxInGroup
為一個矩陣公式。
Original MaxInGroup formula:
MaxInGroup: {=MAX(([@GroupNo]=[GroupNo])*[FullGroupNo])}
Step1
- replace[@GroupNo] with matrix formula with reference only to Name and Revision columns
MIG_1: {=MAX((MATCH([@Name],[Name],0)=[GroupNo])*[FullGroupNo])}
Step2
- Replace (matrix) [GroupNo] with matrix formula with reference to Name and revision columns
MIG_2: {=MAX((MATCH([@Name],[Name],0)=MATCH([Name],[Name],0))*[FullGroupNo])}
到目前為止,一切都按預期進行。
Step3
- Replace (matrix) [FullGroupNo] in MIG_2 with matrix formula with reference to Name and Revidion columns
(so, basicaly I need formula from FGN (Matrix) used before
MIG_3: {=MAX((MATCH([@Name],[Name],0)=MATCH([Name],[Name],0))*(INDEX({0,1},MATCH([Revision],{"","a"},0))/100+MATCH([Name],[Name],0)))}
Note: MIG_3 is part of the Table1 so column names only are enough
So now we could have same values in MaxInGroup, MIG_1-3 columns. But no. We haven't.
The RevPart in MIG_3 depends only on the firs Revision value.
+------+----------+------------+-------+-------+-------+
| Name | Revision | MaxInGroup | MIG_1 | MIG_2 | MIG_3 |
+------+----------+------------+-------+-------+-------+
| A | ="" | 1,01 | 1,01 | 1,01 | 1 |
| A | a | 1,01 | 1,01 | 1,01 | 1 |
| B | ="" | 3 | 3 | 3 | 3 |
| C | ="" | 4,01 | 4,01 | 4,01 | 4 |
| C | a | 4,01 | 4,01 | 4,01 | 4 |
+------+----------+------------+-------+-------+-------+
Versus
+------+----------+------------+-------+-------+-------+
| Name | Revision | MaxInGroup | MIG_1 | MIG_2 | MIG_3 |
+------+----------+------------+-------+-------+-------+
| A | a | 1,01 | 1,01 | 1,01 | 1,01 |
| A | a | 1,01 | 1,01 | 1,01 | 1,01 |
| B | ="" | 3 | 3 | 3 | 3,01 |
| C | ="" | 4,01 | 4,01 | 4,01 | 4,01 |
| C | a | 4,01 | 4,01 | 4,01 | 4,01 |
+------+----------+------------+-------+-------+-------+
Note: ="" means there is a blank string in the cell (formula ="")