[Solved] Week of year over Week of year comparison


(Dvorak) #1

We very often track our metrics by Week of year and I’d like to create table where I will be able to compare values with the previous year.

But also I’d like to display only last X week numbers of year based on current week number.

Let’s say it’s week 4, year 2019 and I want to display only last 3 week numbers: 4, 3, 2 for 2018 and 2019.


The next week I will want to see only week numbers: 5, 4, 3 for 2018 and 2019

I was thinking about custom filter but there is no extract_week function.

How would you approach this? I’ll appreciate any suggestions.


(Izzy) #2

There’s some insight on using a custom filter for this use case here: https://help.looker.com/hc/en-us/articles/360001189687-How-to-do-Period-over-Period-Analysis, which it sounds like you were already thinking about.

If you already have a week num dimension (you can also use the week_of_year timeframe), then you won’t need to use extract_week, right? You can just directly reference that dimension which contains the already extracted weeks, I think.

(Dvorak) #3

Thanks a lot. You’re right and that’s what I am already using.

I was able to solve this by adding new dimension group on current date and then compare this value to any week of year value in custom filter

dimension_group: current {
type: time
timeframes: [time, date, week, month, day_of_week, hour_of_day, raw, week_of_year]
sql: current_date ;;