Forward-Looking Date Filtering in Smarten

Modified on Tue, 18 Aug at 5:16 PM


Use Case: Next 30 Days Technician Availability and Scheduling

A practical approach for preparing technician availability data and enabling rolling future-date filters such as Next 7, Next 15, and Next 30 Days.

Overview

Technician scheduling is inherently forward-looking. Scheduling coordinators need to know which technicians are available tomorrow, next week, or during the next 30 days so that new appointments can be assigned before available capacity is consumed.

Traditional relative-date filters are commonly designed around historical periods such as Yesterday, Last 7 Days, Last 30 Days, Month to Date, or Year to Date. In this use case, the requirement is different: users need a continuously moving future window such as Next 7 Days, Next 15 Days, or Next 30 Days.

The solution combines technician booking and break information with technician working-slot data and a generated Calendar Date Dimension. The calendar derives a numeric DayOffsetFromToday value for each date, allowing a future relative-date requirement to be handled using a standard numeric range filter.

Business Requirement

The objective is to prepare a technician-per-day availability dataset that shows scheduled shift hours, booked hours, break or non-working hours, and remaining available hours, while also identifying how far each date is from the current date.

The resulting analysis should allow scheduling teams to answer questions such as:

  • · Which technicians still have available hours during the next 7 days?
  • · Which technicians have open capacity during the next 30 days?
  • · How much available technician capacity exists by branch?
  • · Which technicians are close to being fully booked?
  • · How much of each technician's scheduled shift is booked, blocked, or still open?

Solution Approach

The core design is to calculate the number of days between today and each reporting date during SSDP data preparation. Once the date is represented as a simple numeric offset, the dashboard can use ordinary numeric filtering instead of depending on a built-in forward relative-date preset.

Stage

Dataset

Purpose

1

Technician Scheduling

Bookings and break / non-working events

2

Technician Working Slot

Rostered shifts and total working hours

 

Stage

Action

Description

1

Standardize to Technician-Day Grain

Aggregate measures to one technician per working date

2

Build Availability Measures

Shift Hours - Booked Hours - Break Hours

3

Join Relative Calendar

Add DayOffsetFromToday and date classification

4

Publish and Filter

Apply 0-7, 0-15, or 0-30 numeric ranges

 

Target Data Grain

Final Grain

One row per technician per working date. The primary business key is ResourceId + StartDate.

 

Establishing a common reporting grain before joining the datasets is essential. Scheduling data may contain many booking and break rows for the same technician and date, while Working Slot data may contain one or more shift rows. Both sides should therefore be normalized to technician-day level before the final join.

If the Working Slot source already contains exactly one row per technician per day, no additional aggregation is required. If multiple shifts can occur on the same day, aggregate them before joining to avoid duplicating daily booking and break measures.

Source Data

1. Technician Scheduling

DT_TechnicianScheduling stores technician appointment bookings and non-working events such as lunch breaks, meetings, scheduling holds, or other blocked time. A technician can therefore have several rows on the same day.

TechName

StartDate

TypeFlag

Activity

Occupied Hrs

Non-Working Hrs

Guy Maisto-9

01-Jun-2026

Working

Repair Equipment

0.5

0.0

Saundra Silva-9

31-May-2026

Non Working

Lunch Break

0.0

0.5

Tony Figueroa-9

01-Jun-2026

Working

PAP - New Setup

1.0

0.0

 

2. Technician Working Slot

DT_Availability_Technician_WorkingSlot stores the rostered working window for each technician, including shift start and end time, branch, and total working hours.

TechName

StartDate

Start Date/Time

End Date/Time

Branch

Total Hrs

Saundra Silva-9

31-May-2026

31-May-2026 11:00

31-May-2026 19:30

Randolph

8.5

Thomas Walker-9

01-Jun-2026

01-Jun-2026 12:00

01-Jun-2026 22:30

Bedford NH

10.5

Guy Maisto-9

31-May-2026

31-May-2026 12:00

31-May-2026 16:00

Fairfield

4.0

 

How the Forward-Date Logic Works

DayOffsetFromToday represents the position of each date relative to the current date. Negative values are historical, zero represents today, and positive values represent future dates.

Calendar Date

DayOffsetFromToday

Meaning

Yesterday

-1

Historical

Today

0

Today

Tomorrow

1

Future

Today + 7 Days

7

Future

Today + 15 Days

15

Future

Today + 30 Days

30

Future

Today + 31 Days

31

Outside the default Next 30 Days view

 

The dashboard can then use the same field for multiple forward-looking ranges:

User Selection

Numeric Range

Next 7 Days

0-7

Next 15 Days

0-15

Next 30 Days

0-30

 

Data Model

Dataset

Type

Grain

Purpose

DT_TechnicianScheduling

Source / Fact

Booking or break row

Raw appointment and non-working events

DT_Availability_Technician_WorkingSlot

Source / Fact

Technician shift row

Raw roster and working hours

DT_TechnicianScheduling_DailyAgg

Derived

Technician-day

Daily booked and break hours

DT_AvailabilityCalendar

Derived / Dimension

Calendar date

Relative-date classification

DT_TechnicianAvailability_Joined

Derived

Technician-day

Combined shift, booking, and break measures

DT_TechnicianAvailability_Next30Days

Published

Technician-day

Dashboard-ready availability dataset

 

Implementation in Smarten SSDP

The implementation can be understood in five phases: prepare the source data, build the relative calendar, prepare technician-day measures, assemble the availability dataset, and publish the final output for dashboard filtering.

Phase 1

Prepare the Source Data

 

Step 1: Load and Standardize Source Fields

Load DT_TechnicianScheduling and DT_Availability_Technician_WorkingSlot into SSDP. Convert StartDate from text, where applicable, to a true Date data type using the source format dd-MMM-yyyy. All downstream date calculations and joins depend on a valid Date field.

Also ensure that OccupiedHours, NonWorkingHours, and TotalHoursWorking are numeric. Blank or space-filled placeholders should be handled during preparation so that later aggregations do not produce unexpected results.

Phase 2

Build the Relative Calendar

 

Step 2: Generate the Calendar Date Dimension

Create a separate Calendar Date Dimension using a Custom Query or Spark SQL query. The calendar should cover the historical and future planning horizon required by the source data. It should not end at +30 days if records beyond the default Next 30 Days view must remain classified in the underlying dataset.

SELECT
    explode(sequence(
        date_sub(current_date(), 90),
        date_add(current_date(), 90),
        interval 1 day
    )) AS CalendarDate

 

The 90-day future range above is only an example. The actual calendar horizon should be aligned with the period retained for scheduling and reporting.

Step 3: Derive DayOffsetFromToday

Add a custom column that calculates the number of days between the current date and CalendarDate.

DayOffsetFromToday = dateDiff("D", current_date(), CalendarDate)

 

Negative values represent past dates, 0 represents today, and positive values represent future dates.

Step 4: Add Date Classification Fields

Create a DateCategory label for display and, if useful, an IsNext30Days convenience flag. DayOffsetFromToday remains the primary field for flexible Next 7, Next 15, and Next 30 Days filtering.

DateCategory = ifCase(DayOffsetFromToday < 0, "Past",
    ifCase(DayOffsetFromToday == 0, "Today", "Upcoming"))

IsNext30Days = ifCase(DayOffsetFromToday >= 0 && DayOffsetFromToday <= 30,
    "Yes", "No")

 

Phase 3

Prepare Technician-Day Measures

 

Step 5: Classify Booked and Non-Working Time

DT_TechnicianScheduling identifies rows using TypeFlag. Working rows contribute OccupiedHours, while Non Working rows contribute NonWorkingHours for breaks or other blocked activities. Confirm that these measures are populated consistently before aggregation.

Step 6: Aggregate Scheduling to Technician-Day Level

Collapse the booking and break rows into one row per technician per date. A GROUP BY query should be used because a windowed Sum operation may repeat a group total across every original row without actually reducing the row count.

SELECT
    ResourceId,
    TechName,
    BranchOfficeName,
    StartDate,
    SUM(OccupiedHours) AS BookedHours,
    SUM(NonWorkingHours) AS BreakHours
FROM DT_TechnicianScheduling
GROUP BY ResourceId, TechName, BranchOfficeName, StartDate

 

Branch Check

Confirm that BranchOfficeName is single-valued for a technician on a given date. If not, define the branch reporting rule before grouping or reattach branch from Working Slot later.

 

Step 7: Normalize Working Slot to Technician-Day Level

Confirm that Working Slot contains one row per ResourceId + StartDate. If multiple shifts can occur on the same date, aggregate those shifts before joining them to daily booking totals.

SELECT
    ResourceId,
    TechName,
    BranchOfficeName,
    StartDate,
    SUM(TotalHoursWorking) AS ShiftHours
FROM DT_Availability_Technician_WorkingSlot
GROUP BY ResourceId, TechName, BranchOfficeName, StartDate

 

Phase 4

Build the Technician Availability Dataset

 

Step 8: Join Working Hours with Booked and Break Hours

Join technician Working Slot data with the daily Scheduling aggregate using ResourceId and StartDate. Use Working Slot as the left side of the join so that rostered technicians remain in the result even when no appointment or break has yet been recorded.

SELECT
    W.ResourceId,
    W.TechName,
    W.BranchOfficeName,
    W.StartDate,
    W.ShiftHours,
    COALESCE(S.BookedHours, 0) AS BookedHours,
    COALESCE(S.BreakHours, 0) AS BreakHours
FROM DT_Availability_Technician_WorkingSlot_Daily W
LEFT JOIN DT_TechnicianScheduling_DailyAgg S
    ON W.ResourceId = S.ResourceId
    AND W.StartDate = S.StartDate

 

Step 9: Calculate Available Hours

Available capacity is calculated by subtracting booked and non-working time from scheduled shift hours.

RawAvailableHours = ShiftHours - BookedHours - BreakHours
AvailableHours = ifCase(RawAvailableHours < 0, 0, RawAvailableHours)

 

For example, an 8.5-hour shift with 5.0 booked hours and 1.0 break hour results in 2.5 available hours.

Step 10: Join the Relative Calendar

Join DT_AvailabilityCalendar to the technician-day availability dataset using StartDate = CalendarDate. This stamps every technician-day row with its relative position from today.

SELECT
    A.*,
    C.DayOffsetFromToday,
    C.IsNext30Days,
    C.DateCategory
FROM DT_TechnicianAvailability_Joined A
LEFT JOIN DT_AvailabilityCalendar C
    ON A.StartDate = C.CalendarDate

 

 

Figure 1: Example SSDP output after preparing technician-day availability measures

Phase 5

Publish and Configure Dashboard Filtering

 

Step 11: Publish the Final Dataset

Remove intermediate fields not needed for reporting, such as RawAvailableHours and duplicated join keys, and publish the dashboard-ready dataset as DT_TechnicianAvailability_Next30Days.

The published dataset should retain ResourceId, TechName, BranchOfficeName, StartDate, ShiftHours, BookedHours, BreakHours, AvailableHours, DayOffsetFromToday, DateCategory, and IsNext30Days.

Step 12: Configure the Forward-Date Filter

Bind the dashboard filter to DayOffsetFromToday as a numeric range. Set the default range to 0-30 to show today through the next 30 days. The same field can support additional quick selections such as 0-7 and 0-15.

Filter Option

DayOffsetFromToday Range

Next 7 Days

0-7

Next 15 Days

0-15

Next 30 Days

0-30

 

IsNext30Days can optionally be exposed as a simple Yes/No toggle. Because StartDate remains available, users can still apply a conventional date filter for historical or custom-period analysis where required.

Expected Output

The final output contains one row per technician per date, combining technician capacity measures with the forward-date classification required by the dashboard.

TechName

Branch

StartDate

DayOffset

Shift

Booked

Break

Available

Next 30?

Guy Maisto-9

Fairfield

18-Jul-2026

1

4.0

1.5

0.5

2.0

Yes

Thomas Walker-9

Bedford NH

10-Aug-2026

24

10.5

6.0

1.0

3.5

Yes

Saundra Silva-9

Randolph

05-Sep-2026

50

8.5

5.0

1.0

2.5

No

 

With DayOffsetFromToday filtered between 0 and 30, the first two rows remain visible. The third row remains in the underlying dataset but is excluded from the default Next 30 Days view because it is 50 days from today.

Refresh and Operational Considerations

Keep the Relative Window Dynamic

DayOffsetFromToday is calculated when the dataset is refreshed. A record that has an offset of 10 today should have an offset of 9 tomorrow. The Calendar Dimension and dependent final dataset should therefore refresh regularly, typically once per day, so the rolling future window moves with the current date.

Data Considerations

  • · Multiple shifts per day: aggregate Working Slot to technician-day level before joining daily booking totals.
  • · Multiple branches: define the required branch reporting rule if a technician can work in more than one branch on the same day.
  • · Missing scheduling records: the left join from Working Slot keeps rostered technicians visible even when no booking or break exists.
  • · Bookings without a working slot: the current design treats Working Slot as the driving dataset, so scheduling rows without a corresponding rostered shift are excluded unless a separate reconciliation rule is added.
  • · Over-booking: floor AvailableHours at zero so over-booked days do not display negative availability.
  • · Calendar horizon: ensure the Calendar Date Dimension extends across every date that needs relative-date classification, including dates beyond the default Next 30 Days view.

Conclusion

This use case demonstrates how Smarten SSDP can support forward-looking relative-date analysis by deriving a numeric day offset from the current date. By combining rostered working hours, appointment bookings, non-working time, and a Calendar Date Dimension, the final dataset provides both technician capacity and the relative-date information required for future-period filtering.

The dashboard can then support flexible selections such as Next 7 Days, Next 15 Days, and Next 30 Days using a standard numeric range on DayOffsetFromToday, enabling scheduling teams to identify open technician capacity before future schedules fill up.


Tags: Date Filtering, scheduling, Forward dates filter, Future date filter,

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article