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.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