Create custom filter for start of the week.

Periscope has the default aggregation which takes week start from Monday. Some times we need a week starting from Wednesday or some other days.

code:-

case
  when [value] = 'week_monday'
    then date_trunc('week', [column]::timestamp)::date
  when [value] = 'week_tuesday'
    then date_trunc('week', [column] - '1 day '::interval )::date + '1 day'::interval
  when [value] = 'week_wednesday'
    then date_trunc('week', [column] - '2 day'::interval )::date + '2 day'::interval
  when [value] = 'week_thursday'
    then date_trunc('week', [column] - '3 day '::interval )::date + '3 day'::interval
  when [value] = 'week_friday'
    then date_trunc('week', [column] - '4 day '::interval )::date + '4 day'::interval
  when [value] = 'week_saturday'
    then date_trunc('week', [column] - '5 day '::interval )::date + '5 day'::interval
  when [value] = 'week_sunday'
    then date_trunc('week', [column] - '6 day '::interval )::date + '6 day'::interval
  when [value] = 'month'
    then date_trunc('month', [column])::date
  when [value] = 'quarter'
    then date_trunc('quarter', [column])::date
  when [value] = 'year'
    then date_trunc('year', [column])::date
  when [value] = 'daily'
    then date_trunc('day', [column])::date
  when [value] is not null
    then date_trunc([value], ([column])::timestamp)::date
  else date_trunc('date', ([column])::timestamp)::date
end

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 4 mths agoLast active
  • 48Views
  • 1 Following