Question

Period over Period week of year

  • 11 June 2021
  • 2 replies
  • 142 views

HelloPlease, from a custom filter, the user chooses a date interval I want to compare the number of this week to the number of the same week last year

Thanks


This topic has been closed for comments

2 replies

Userlevel 6
Badge +1

There are many posts already about period over period comparison. Check them out:

https://community.looker.com/search?q=period%20over%20period

@Dawid please can i have a code lookml to Comparing a Previous Week to that Same Week Last Year from this example.

Thanks

 

dimension: period_comparison {


case: {


when: {


sql: ${date} >= DATE_TRUNC('month', GETDATE())


AND ${date} < DATE_TRUNC('day', GETDATE());;


label: "current_month"


}





when: {


sql: ${date} >= DATE_TRUNC('month', GETDATE() - interval '1 year')


AND ${date} < DATE_TRUNC('day', GETDATE() - interval '1 year');;


label: "last_year_same_month_same_point"


}





when: {


sql: ${date} >= DATE_TRUNC('month',GETDATE()) - interval '1 month'


AND ${date} < DATE_TRUNC('day', GETDATE() - interval '1 month');;


label: "last_month_same_point"


}





else: "unknown"


}


}