Repository navigation
Rolling date windows: filter_last_days, and last_days / table_pivot on simple_dashboard - #10
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).
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 hiddenIf([Col] >= DateAdd("day", -N, Today()), 1, 0)column and anumber-rangefilter keeping 1 (the same filter kindtable(window=)already emits), soToday()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 baddays, or the same column limited twice. Composes withfilter_by_value.simple_dashboard:date_column=plus a'last_days': Nkey 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 totable_columns, for totals by group rather than row-by-row (mutually exclusive, enforced).schema.ymland the README; newsigma_last_days_dashboardintegration model, golden file, assertions, and 6 negative cases.Default behavior is unchanged: nothing is windowed unless
last_daysis given.Test plan
UPDATE_GOLDEN=1 PARSE_FLAGS=--warn-error bash scripts/run_integration_tests_duckdb.shon dbt 1.12.5 / dbt-duckdb 1.11.0: all pass (96 negative cases, schema and layout checks); the only new golden issigma_last_days_dashboard.json🤖 Generated with Claude Code