Google sheets 从列标题返回列值
在回答我的问题时(我将保留下面的链接),使用的公式和结果如下: 列可以更改位置,但每个列的标题都跟随新的列位置,因此我如何要求公式来搜索标题为X的列的位置,并从中找到Google sheets 从列标题返回列值,google-sheets,google-sheets-formula,Google Sheets,Google Sheets Formula,在回答我的问题时(我将保留下面的链接),使用的公式和结果如下: 列可以更改位置,但每个列的标题都跟随新的列位置,因此我如何要求公式来搜索标题为X的列的位置,并从中找到⚽ 匹配项 在这种情况下,该值为: 通过VLOOKUP解释: =ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B2:B),B1:F,3,FALSE))) VLOOKUP的问题在于标题为X的列可能并不总是在列D和⚽ 匹配项不一定总是在列B中使用: =ARRAYFORMULA(IFERROR(VLOO
⚽ 匹配项
在这种情况下,该值为:
通过VLOOKUP解释:
=ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B2:B),B1:F,3,FALSE)))
VLOOKUP
的问题在于标题为X
的列可能并不总是在列D
和⚽ 匹配项不一定总是在列B中使用:
=ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B2:B),
{FLATTEN(QUERY(TO_TEXT(TRANSPOSE(IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr"))),
"where Col1 contains 'Matches'", 0)), IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr")}, 5, 0)))
这部分是:
=INDEX(FLATTEN(QUERY(TO_TEXT(TRANSPOSE(IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr"))),
"where Col1 contains 'Matches'", 0))
完整公式如下:
=ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B2:B),
{FLATTEN(QUERY(TO_TEXT(TRANSPOSE(IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr"))),
"where Col1 contains 'Matches'", 0)), IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr")},
MATCH("X", INDEX(IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr"), 1), 0)+1, 0)))
非常感谢,伙计,我有一个疑问,因为如果标题为X
的列碰巧从第四列更改为第三列,结果将返回错误,将有某种方法来定义而不是4
,将值列搜索如X
?@BrondbyIF yes。答案已更新。代码:MATCH(“X”),索引(IMPORTXML(“https://www.soccerstats247.com/predictions/brazil/serie-a/“,”//表[@id='soccerContentPlaceHolder']/tbody/tr”),1),0)
=ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B2:B),
{FLATTEN(QUERY(TO_TEXT(TRANSPOSE(IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr"))),
"where Col1 contains 'Matches'", 0)), IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr")},
MATCH("X", INDEX(IMPORTXML(
"https://www.soccerstats247.com/predictions/brazil/serie-a/",
"//table[@id='soccerContentPlaceHolder_gv1X2Predictions']/tbody/tr"), 1), 0)+1, 0)))