Home > front end >  Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " <ID&
Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " <ID&

Time:04-01

My exact formula below used to work previously and without changing anything except adding more data to my master table whereby 'Premium Advertisers' is populated, I get the following error:

"Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " "s "" at line 1, column 2168."

Please see my query below, doesn't make sense why it's picking up an error in the 2168th character of my select statement. I've tried only using a small sample of my master data table and I still get the same error.

=QUERY('Premium Advertisers'!A2:G, "select * where A matches '" & "^" & textjoin("$|^", true, 'Premium Advertisers'!I2:I) & "$' ",0)

CodePudding user response:

you got there a name which contains ' (Hill's Pet Nutrition South Africa (Pty) Limited). therefore try:

=INDEX(SUBSTITUTE(QUERY(SUBSTITUTE('Premium Advertisers'!A2:G, "'", "♦"), 
 "where Col1 matches '^"&TEXTJOIN("$|^", 1, 
 SUBSTITUTE('Premium Advertisers'!I2:I, "'", "♦"))&"$'", ), 
 "♦", "'"))

enter image description here


update

we also need to skip reserved regex characters like parenthesis () with \(\)

=FILTER(A:D, REGEXMATCH(A:A, TEXTJOIN("|", 1, 
 SUBSTITUTE(SUBSTITUTE(I2:I, "(", "\("), ")", "\)"))))

enter image description here

  • Related