Reformatting month name for chart axis

done
low_priority
reply

(Simon Clark) #1

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.


(Izzy) #2

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.


(Simon Clark) #3

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.


(Izzy) #4

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.


(Simon Clark) #5

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