Not sure how production manageable it would be for you and it's basically a SQL vanity visual. I literally do all the formatting in SQL and just pull it in as a table into Metabase. It works though and I use it for basic visualising marketing campaigns etc from a lookup I maintain. I use Redshift so the SQL might not work like for like for you. Also I get the odd error about recursive cte's but I do my best to avoid them. As I say, it's hacky and fun at the same time
You could easily get around the CTE by materlialzing the table then boom, you're off!
This is an example for the whole year
SQL
WITH RECURSIVE numbers(n) AS (
SELECT 0 AS n
UNION ALL
SELECT n + 1
FROM numbers
WHERE n < 365 -- Adjust for leap years if needed
),
year_calendar AS (
SELECT
DATEADD(day, n, DATE_TRUNC('year', CURRENT_DATE)) AS date
FROM numbers
),
-- my events lookup which I drive dynamically
events AS (
SELECT
DATE '2024-01-15' AS date, 'Marketing launch' AS description
UNION ALL
SELECT
DATE '2024-02-14', 'Valentine\'s Day campaign'
UNION ALL
SELECT
DATE '2024-12-25', 'Christmas sale'
),
formatted_calendar AS (
SELECT
c.date,
EXTRACT(DAY FROM c.date) AS day_number,
EXTRACT(DOW FROM c.date) AS day_of_week,
EXTRACT(MONTH FROM c.date) AS month_number,
TO_CHAR(c.date, 'FMMonth') AS month_name,
EXTRACT(YEAR FROM c.date) AS year_number,
FLOOR((EXTRACT(DAY FROM c.date) + EXTRACT(DOW FROM DATE_TRUNC('month', c.date)) - 1) / 7) + 1 AS week_of_month,
e.description
FROM year_calendar c
LEFT JOIN events e ON c.date = e.date
)
SELECT
month_number,
month_name,
MAX(CASE WHEN day_of_week = 0 THEN CONCAT(day_number, COALESCE(' - ' || description, '')) END) AS Sunday,
MAX(CASE WHEN day_of_week = 1 THEN CONCAT(day_number, COALESCE(' - ' || description, '')) END) AS Monday,
MAX(CASE WHEN day_of_week = 2 THEN CONCAT(day_number, COALESCE(' - ' || description, '')) END) AS Tuesday,
MAX(CASE WHEN day_of_week = 3 THEN CONCAT(day_number, COALESCE(' - ' || description, '')) END) AS Wednesday,
MAX(CASE WHEN day_of_week = 4 THEN CONCAT(day_number, COALESCE(' - ' || description, '')) END) AS Thursday,
MAX(CASE WHEN day_of_week = 5 THEN CONCAT(day_number, COALESCE(' - ' || description, '')) END) AS Friday,
MAX(CASE WHEN day_of_week = 6 THEN CONCAT(day_number, COALESCE(' - ' || description, '')) END) AS Saturday
FROM formatted_calendar
GROUP BY month_number, month_name, week_of_month
ORDER BY month_number, week_of_month;