Skip to content

Rolling date windows: filter_last_days, and last_days / table_pivot on simple_dashboard - #10

Merged
mattsenicksigma merged 1 commit into
mainfrom
feat/last-days-filter
Oct 13, 2026
Merged

mattsenicksigma merged 1 commit into
mainfrom
feat/last-days-filter

Conversation

@mattsenicksigma

Copy link
Copy Markdown
Collaborator

Summary

Reports have no date control, so a "last 7 days" breakdown next to an all-time trend has to be built into the element. Today that means hand-rolling a hidden column and filter outside the package (the OpenRouter cost report in dbt-sos does exactly that).

  • New filter_last_days(element, column, days): limits one chart, KPI or table to the last N days of a date column, measured from the day the report renders. Adds a hidden If([Col] >= DateAdd("day", -N, Today()), 1, 0) column and a number-range filter keeping 1 (the same filter kind table(window=) already emits), so Today() is evaluated by Sigma at render time and a scheduled report never goes stale. Fails loudly (not silently unscoped) on a non-warehouse element, a bad days, or the same column limited twice. Composes with filter_by_value.
  • simple_dashboard: date_column= plus a 'last_days': N key on any KPI, chart or the pivot, so elements are windowed individually and the rest keep full history.
  • simple_dashboard: table_pivot={'rows', 'cols', 'values', 'name', 'h', 'last_days'} as an alternative to table_columns, for totals by group rather than row-by-row (mutually exclusive, enforced).
  • Documented in schema.yml and the README; new sigma_last_days_dashboard integration model, golden file, assertions, and 6 negative cases.

Default behavior is unchanged: nothing is windowed unless last_days is given.

Test plan

  • UPDATE_GOLDEN=1 PARSE_FLAGS=--warn-error bash scripts/run_integration_tests_duckdb.sh on dbt 1.12.5 / dbt-duckdb 1.11.0: all pass (96 negative cases, schema and layout checks); the only new golden is sigma_last_days_dashboard.json
  • dbt 2.x CI
  • Confirm live in Sigma: not exercised here; the filter kind is the same one windowed tables use, and the compiled spec validates against Sigma's request schema

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@mattsenicksigma
mattsenicksigma merged commit e5f0419 into main Oct 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant