Counts over time for things that have a start date and end date

Hi, I work for a recruitment company where we have contractors working. Does anyone know how I count the number of contractors out working over time when I have to take into account both a start and an end date? Without this I am unable do do any trends for my senior management!
Many thanks
Zena
Best Answer
-
Thanks Jae, I'll give the SQL a go then!
0
Answers
-
Hey Zena, it's hard to address your question if we don't know how your data is currently structured (what's the granularity? can you provide a sample dataset?) What are the metrics you want to sho in your trend report?
If i had to guess you want to do something like the report "how many contractors were working on March 1 and your data is one row per contractor per contract and the start and end date of their engagement on that contract. if that's the casse you need to JOIN the transactions to a date dimension using MySQL something like...
select
t.*
d.date
FROM
contractor_transactions t
INNER JOIN
date d
ON d.date between t.startDate and t.endDate
make sure your contract strat and end dates are always populated or you'll exclude rows in your JOIN
select
t.*
d.date
FROM
contractor_transactions t
INNER JOIN
date d
ON d.date between t.startDate and coalesce(t.endDate, current_date)
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Hi Jae,
Thanks for coming back to me, Your assumptions about how the data is structured are correct, but I've only used ETL and don't know SQL. Is there anyway to achieve the same result using ETL?
Zena
0 -
Magic ETL does not support non-equi JOINs so ... no. The pseudo code I provided should work if you swap out table and field names.
0 -
Thanks Jae, I'll give the SQL a go then!
0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 310 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 113 SQL DataFlows
- 650 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 791 Beast Mode
- 78 App Studio
- 43 Variables
- 753 Automate
- 187 Apps
- 478 APIs & Domo Developer
- 71 Workflows
- 17 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 407 Distribute
- 118 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 141 Manage
- 137 Governance & Security
- 8 Domo Community Gallery
- 47 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive