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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 737 Beast Mode
- 55 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive