[英]How to run Google-sheets query on text cell containing asterisk
When I use this query in Google sheets当我在 Google 表格中使用此查询时
=QUERY('Kontoutdrag länsförsäkringar'!$A$3:$F$1000186;"SELECT sum(F) WHERE B >= date'" & TEXT(DATEVALUE(J$4);"yyyy-mm-dd") & "' AND B <= date '"& TEXT(DATEVALUE(J$5);"yyyy-mm-dd") &"' AND D matches '" & JOIN("|";$T10:$CZ10) &"' AND D != '' label sum(F)'' ")
It will skip any cell that contains an asterisk somewhere in the text, the character它将跳过文本中某处包含星号的任何单元格,字符
*
The error is in this match part错误在这个匹配部分
AND D matches '" & JOIN("|";$T10:$CZ10)
If the D column's text (and the corresponding, identical cell in the join range) contains an asterisk it will not match.如果 D 列的文本(以及连接范围内相应的相同单元格)包含星号,则它将不匹配。
Is there a way to escape this so that I can have cells with the asterisk in the text?有没有办法避免这种情况,以便我可以在文本中使用带有星号的单元格?
This value will work这个值会起作用
K Batteriexp
This value will not be picked up by the query查询不会选取此值
K*Batteriexp
If asterisk is the only problem, You can escape it using regex:如果星号是唯一的问题,您可以使用正则表达式将其转义:
AND D matches '" & ARRAYFORMULA(JOIN("|";REGEXREPLACE($T10:$CZ10,"\*","\\*")))
This这个
K*Batteriexp //Means 'K' repeated 0 or more times
becomes变成
K\*Batteriexp //means a literal *
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.