I have a cost_table with columns in BigQuery:
country | start_date_of_campaign | end_date_of_campaign | spend | currency |
---|---|---|---|---|
DE | 2022-10-05 | 2022-10-15 | 10 | EUR |
DK | 2022-09-07 | 2022-09-23 | 20 | DKK |
After a cross join with date_dimensions table I have a cost_table_exploded on sort of daily granularity. All the dates between start_date and end_date of campaign get a new row. The column spend is converetd into total_spend (sum(spend)). Result:
country | start_date_of_campaign | end_date_of_campaign | total_spend | currency | date |
---|---|---|---|---|---|
DE | 2022-10-05 | 2022-10-07 | 10 | EUR | 2022-10-05 |
DE | 2022-10-05 | 2022-10-07 | 10 | EUR | 2022-10-06 |
DE | 2022-10-05 | 2022-10-07 | 10 | EUR | 2022-10-07 |
DK | 2022-09-07 | 2022-09-23 | 20 | DKK | 2022-09-23 |
I need to enrich the cost_table_exploded with spend in euro.
I have a currency dimensions table that is on monthyl granularity with columns:
currency_name | valid_from_date | to_euro_conversion |
---|---|---|
DKK | 2022-10-01 | 0,13460 |
DKK | 2022-09-01 | 0,13450 |
DKK | 2022-08-01 | 0,13445 |
DKK | 2022-07-01 | 0,13455 |
EUR | 2022-10-01 | 1 |
EUR | 2022-09-01 | 1 |
How do I join table on monthly granularity to table on daily granularity?