Question

Escaping commas in string filters for a dashboard

  • 14 April 2015
  • 1 reply
  • 311 views

Issue


Hi all, I have an issue with escaping commas in string filters. I have this line in my dashboard LookML:


default_value: "San Francisco, East Bay, Portland, Washington, D.C.", 

and Looker treats “Washington” and “D.C.” as 2 separate strings, which is not desired.


Notes


First thing I tried is to escape the comma with a backslash, like below:


default_value: "San Francisco, East Bay, Portland, Washington\, D.C."

but this gives me a “parsing error” in Looker. Then I used double backslashes:


default_value: "San Francisco, East Bay, Portland, Washington\\, D.C."

Now there wasn’t any parsing errors, but this eliminated the space after that comma, which is not desired.


According to http://www.looker.com/docs/reference/filter-expressions, I modified my line to


default_value: "San Francisco", "East Bay", "Portland", "Washington, D.C.", 

However this also gives me a “parsing error”. Then I tried using single quote to enclose the whole thing, like below:


default_value: '"San Francisco", "East Bay", "Portland", "Washington, D.C."', 

This successfully gets rid of the parsing error, but now the filter strings were not rendered well, and I lost the ability to click on the 4 strings like I can do with a button —I have to edit the text itself in the filter inputbox.


Then I tried using ^ to escape the comma:


default_value: "San Francisco, East Bay, Portland, Washington^, D.C."

This also works, but again, I couldn’t click on the strings like buttons.


##Question ##

What’s the best practices here and how did you do it? Thanks!


1 reply

Userlevel 4

Hi Xiaolong, unfortunately I don’t think this is possible at the moment with exact-match. One hack to make the buttons clickable would just be to use ‘starts with’ or ‘ends with’ and use the section before or after the comma (ie. starts with [San Francisco, East Bay, Portland, Washington] or ends with [San Francisco, East Bay, Portland, D.C.]).

Reply