SUM 不同电子表格中的总数
SUM the total in different spreadsheets
我有两个 spreadsheets,在 1 中我有几个食谱。在另一个 sheet 中,客户可以选择 2 个食谱。我想对每个 selected 食谱的总数求和,但我不知道如何在 google 传播sheet 中做到这一点。我想到了下面的算法。
所选食谱(列 + 1):(行 + 4)
即如果客户端select
食谱 1 (A + 1) = B : (1 + 4) = 5
总计 = B:5
食谱 3 (A + 1) = B : (7 + 4) = 11
总计 = B:11
您的数据确实没有以 excel 可读的格式设置。如果你想让它更容易扩展(比如如果你有很多食谱),你应该将数据设置成这样并使用这个公式
=iferror(index(F19:F20,match(A23,A19:A20,0)),0)+iferror(index(F19:F20,match(B23,A19:A20,0)),0)
如果您真的想使用当前的数据格式,可以为每个配方使用 if 语句
=if(A14="Recipe 1",B5,if(A14="Recipe 2",E5,if(A14="Recipe 3",B11,if(A14="Recipe 4",E11,0))))+if(B14="Recipe 1",B5,if(B14="Recipe 2",E5,if(B14="Recipe 3",B11,E11,if(B14="Recipe 4",E11,0))))
使用:
=ARRAYFORMULA(SUM(QUERY(SPLIT(TRIM(FLATTEN(
SPLIT(QUERY(FLATTEN(IFERROR(IFNA(REGEXEXTRACT(Sheet1!A1:E,
TEXTJOIN("|", 1, G1:I1))), "♠"&Sheet1!A1:E&"♦")),,9^9), "♦"))), "♠"),
"select Col2 where Col1 matches '"&G1&".+|"&H1&".+'", 0)))
spreadsheet demo
我有两个 spreadsheets,在 1 中我有几个食谱。在另一个 sheet 中,客户可以选择 2 个食谱。我想对每个 selected 食谱的总数求和,但我不知道如何在 google 传播sheet 中做到这一点。我想到了下面的算法。
所选食谱(列 + 1):(行 + 4)
即如果客户端select
食谱 1 (A + 1) = B : (1 + 4) = 5 总计 = B:5
食谱 3 (A + 1) = B : (7 + 4) = 11
总计 = B:11
您的数据确实没有以 excel 可读的格式设置。如果你想让它更容易扩展(比如如果你有很多食谱),你应该将数据设置成这样并使用这个公式
=iferror(index(F19:F20,match(A23,A19:A20,0)),0)+iferror(index(F19:F20,match(B23,A19:A20,0)),0)
如果您真的想使用当前的数据格式,可以为每个配方使用 if 语句
=if(A14="Recipe 1",B5,if(A14="Recipe 2",E5,if(A14="Recipe 3",B11,if(A14="Recipe 4",E11,0))))+if(B14="Recipe 1",B5,if(B14="Recipe 2",E5,if(B14="Recipe 3",B11,E11,if(B14="Recipe 4",E11,0))))
使用:
=ARRAYFORMULA(SUM(QUERY(SPLIT(TRIM(FLATTEN(
SPLIT(QUERY(FLATTEN(IFERROR(IFNA(REGEXEXTRACT(Sheet1!A1:E,
TEXTJOIN("|", 1, G1:I1))), "♠"&Sheet1!A1:E&"♦")),,9^9), "♦"))), "♠"),
"select Col2 where Col1 matches '"&G1&".+|"&H1&".+'", 0)))