Looker Community

Plotting month-over-month as two lines

I’m trying to do something that seems very common. In the below example (thought I don’t need quite this many things at once, this is just a good example), there’s a month-to-date line for sales this month, overlayed on last months sales.

That’s a common pattern I’ve used in other tools to track how we are doing versus last month. (This one also has a nice goal line feature, but that’s a topic for another post…)

By doing a pivot on the month and selecting two months, I can get them both plotted, but they aren’t overlayed, of course. They are next to each other, like this:

I want that graph, but have the October data compared directly to September data.

Is there a common Looker-community pattern for this?

@wkoffel The way I would recommend doing this is to pivot on the Month timeframe, and then add the Day of Month timeframe as a regular dimension. (Also add your desired measure). If you filter to only show data for two months, you’ll end up with something like this, which shows each month side by side:

1 Like

Thank you @lindsey. I had tried getting the day_of_month through various other calculations, but totally forgot that it was one of the available timeframes. Everything from there was obvious and works well. Much obliged.

Hello, what date field should I use if I want to have month names showing instead of days. So I would be comparing 2018 and 2017 and have month names on x axis ?

@Christine_Kelly
Is this what you’re looking to do:

You can just pivot on the Year and select Month Name.

By having a filter on the Month Name also, you can quickly flip between individual months for a YoY comparison also:

1 Like

cool yes!!! I just need to add month name in my dimensions:)
Thanks that is great

Thanks @lindsey! Is there a way to show also the percentage change from each month’s days? In your example, -25% 1st day, 8% 2nd day, -10% 3rd day… I try to include the calculation, but it creates two calculation columns since it is pivoted I guess. Thanks for any pointers!

edit: For anyone else also wondering how to achieve this: https://help.looker.com/hc/en-us/articles/360023509454-Calculating-Percent-of-Previous-and-Percent-Change-with-Table-Calculations