compare today's data with same day last week

206 Views Asked by At

I am looking for a date function to compare data today vs lastweek sameday . e.g Wednesday this week vs Wednesday last week. I am particularly looking to write in Domo (BI TOOL) but any language(sql ) would be appreciated.

Thanks

I can not find a way to write formula in Domo .

3

There are 3 best solutions below

1
Venkat On
SELECT *
FROM your_table
WHERE DAY_OF_WEEK(your_date_column) = DAY_OF_WEEK(CURRENT_DATE)
  AND DATE_DIFF(your_date_column, CURRENT_DATE, WEEK) = 1
2
Raman Sharma On
select *
from your_table y1
left join your_table y2 on y1.date -7 = y2.date
0
user1191247 On

It is not clear what you are trying to achieve. Are you wanting to compare aggregate values between the two dates?

This would give you two rows, one for today (Thursday) and another for last Thursday:

SELECT date_col, SUM(something), AVG(something_else)
FROM your_tabl
WHERE date_col = CURRENT_DATE
   OR date_col = DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK)
GROUP BY date_col

I have used the functions documented on Beast Mode Functions Reference Guide.