Fourth model
Staffing accuracy
Fourth's productivity view: of the hours worked each day, how many were at the right staffing level, and how many under or over the requirement.
- Grain
- date x location
- Built from
- 1Raw tables
- 1Staging
- 1Core
- 1Analytics
- Reads from Fourth
- labour_daily_summary
- Ships as
- Weld and dbt SQL, open source on GitHub
core.fourth.staffing_accuracy
1-- core.fourth.staffing_accuracy
2-- Fourth's productivity view: of the hours worked each day, how many were at the
3-- right staffing level, and how many under or over the requirement.
4-- Grain: date x location.
5--
6-- Shares are computed per row over correctly + under + over staffed hours.
7-- Re-aggregate by summing the hour columns and dividing, not by averaging shares.
8
9SELECT
10 date,
11 location_id,
12 location_name,
13 correctly_staffed_hours,
14 understaffed_hours,
15 overstaffed_hours,
16 passive_hours,
17 SAFE_DIVIDE(correctly_staffed_hours, correctly_staffed_hours + understaffed_hours + overstaffed_hours) AS correctly_staffed_share,
18 SAFE_DIVIDE(understaffed_hours, correctly_staffed_hours + understaffed_hours + overstaffed_hours) AS understaffed_share,
19 SAFE_DIVIDE(overstaffed_hours, correctly_staffed_hours + understaffed_hours + overstaffed_hours) AS overstaffed_share
20FROM {{staging.fourth.labour_daily_summary}}This model and the 2 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().
Notes
How it counts. And where it stops.
Shares are computed per row over correctly + under + over staffed hours. Re-aggregate by summing the hour columns and dividing, not by averaging shares.
Raw tables it reads
- raw.fourth.labour_daily_summary
Put Fourth in front
of your agents.
Connect Fourth, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.