Question

Reformatting month name for chart axis

  • 8 March 2019
  • 4 replies
  • 1247 views

Does anyone know a way to reformat a month name time dimension which is used as a chart axis so it’s displayed as Jan, Feb, Mar etc?



This would be equivalent of using %b for Time Label Format, which I can’t do because the month name dimension is a string not a date, and I can’t want to use the full date as I’m pivoting on year for YoY comparison.



I can add my own short month name dimension but thought I’d throw it out here in case anyone had a better idea.


4 replies

Userlevel 7
Badge +1

I can’t think of a way to do this using time formatting options— Sounds like a short month name dimension is the best way to me. If you really wanted to preserve the underlying full month name, you could use the html: parameter and liquid to take a substring of the first 3 characters like


html: {{value | slice: 0,3 }}



But, that feels like overkill when you could make a dimension and keep things clearer.

Thanks @izzy, I didn’t think there was a better option but no harm in asking!



Incidentally, is there any documentation on the functions/commands that can be used such as slice in your liquid example here? I’ve seen urlencode and possibly others mentioned before.

Userlevel 7
Badge +1

We have our Looker Liquid Variable Reference here: https://docs.looker.com/reference/liquid-variables which includes most variables relating to Looker, BUT, liquid is actually something that shopify built, so their documentation has the full list of functions and operators: https://shopify.github.io/liquid/basics/introduction/.



We’ve removed some/some just don’t work due to the fact that Looker’s a data analytics platform, not a web sales platform (I can’t imagine you’d find the shipping_method tag too useful!) but a lot of them work. You can actually do for loops in Liquid which is crazy— I know @jesse.carah has built some cool stuff with that.

Thanks @izzy - def looks like some of those functions & operators could be useful.

Reply