ETL - How to spread a Budget over two dates within a variable date range.
I have various start and end dates for campaigns. I know how to calculate the # of days between any get set of dates. But, what I am trying to set up in the etl is this - if I have a budget amount, start date and end date, what is the easiest way for me to have the etl calculate the division of the budget over the given start and end dates?
e.g. let's say I have a $9800 budget, and I set the start date/end date for 4/17/2024 - 10/12/2024. I want it evenly distributed over the number of days, etc.
I would want the to know a couple metrics from these inputted values,
The Daily Budget
The Monthly Budget (taking into account that April and October are not full months)
And those values projected for future months.
Is there a way to set this up in the ETL?
Best Answer
-
The easiest way would be to use a date dimension table and a cross join (Cartesian Product). Say you have your budget dataset.
You would join your date dimension table (a dataset that has a row for every day) with your budget dataset.
You would then filter to where dt (the day in your date dataset is >= start_date and < = end_date.
You can then calculate the number of days between your start and end dates. Note, you could also make use of the "Date Operations" tile if you wanted the number of working days between these dates. Then divide your total budget by the number of days to get the daily budget.
For the monthly the easiest way would be to connect this dataset to a card and then aggregate the daily total by month.
For example
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**1
Answers
-
The easiest way would be to use a date dimension table and a cross join (Cartesian Product). Say you have your budget dataset.
You would join your date dimension table (a dataset that has a row for every day) with your budget dataset.
You would then filter to where dt (the day in your date dataset is >= start_date and < = end_date.
You can then calculate the number of days between your start and end dates. Note, you could also make use of the "Date Operations" tile if you wanted the number of working days between these dates. Then divide your total budget by the number of days to get the daily budget.
For the monthly the easiest way would be to connect this dataset to a card and then aggregate the daily total by month.
For example
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**1 -
Hi David,
My apologies for my late reply. Thank you for the detailed response! I set this up, so the budgets appear on each day.
I do have another follow-up question, if you have two datasets, one primary, and the other the calendar dataset, and both have date columns. So eventhough there is a unique identifier, because they are repeated multiple times per day, with various other metrics. What would be the best method to joining to avoid a one to many join? As it stands now, the current join, produces millions of rows. I know that I can include additional join keys, but is there another option if that isn't as efective? The data is updated daily.
Thanks again for your help.
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive