Solved

Tabs, New Lines, etc. in String Dimension

  • 13 January 2021
  • 1 reply
  • 41 views

Userlevel 2

I have noticed that string formatting is stripped away in Looker. Example, if I have a string Dimension and the underlying data contains tabs or line feeds, this formatting is removed in the resulting Looker query.

 

Are there any ways to change that behavior?

icon

Best answer by fabio 13 January 2021, 21:35

I think the effect you’re referring to is actually the result of the browser’s default behavior for text content. The data should still contain that whitespace if you download it as a csv, for example.

If you add an html declaration to your dimension, you can be more explicit about how it is displayed in the browser, including by using a `<pre>` tag or using a `style=”white-space:...”` attribute

So approximately this:
dimension: foo {
  ...
  html:<div style="white-space:pre">{{value}}</div>;;
}

View original

1 reply

Userlevel 6

I think the effect you’re referring to is actually the result of the browser’s default behavior for text content. The data should still contain that whitespace if you download it as a csv, for example.

If you add an html declaration to your dimension, you can be more explicit about how it is displayed in the browser, including by using a `<pre>` tag or using a `style=”white-space:...”` attribute

So approximately this:
dimension: foo {
  ...
  html:<div style="white-space:pre">{{value}}</div>;;
}

Reply