/semantic-models:date-tablefrom semantic-models
Adds a 58-column DimDate date dimension to a PBIP semantic model via a bundled Power Query function, plus a "Dates Selected" title measure.
Ships in semantic-models. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Adds a fully-formed date dimension to a Power BI Project (PBIP) semantic model, plus the
companion measure that turns the current date selection into a readable report title
(Selected Period: Jan - Mar 2024).
The assets are TMDL, so this works on a PBIP folder on disk with no Power BI Desktop, Tabular Editor, or network access required.
The two substantial pieces of code here are community work, redistributed with credit. Keep the attribution headers in the TMDL when you copy these assets anywhere.
| Asset | Author | Source |
|---|---|---|
FunctionDateTable (Extended Date Table M function) | Melissa de Korte | Enterprise DNA forum · gist · taken from Brian Julius's mirror |
Dates Selected measure | Rick de Groot / Datahub | Showing period selections in Power BI |
Neither is published under an explicit licence; both were shared freely by their authors.
The column renames, added columns, and removed ISO columns in the bundled version are
local modifications -- see references/column-reference.md.
| File | Contents |
|---|---|
definition/tables/DimDate.tmdl | The date table: 58 columns, sort-by columns and format strings already set, plumbing columns tucked into a zOther display folder |
definition/expressions.tmdl | FunctionDateTable, the M function that generates the rows |
definition/tables/Measure Table.tmdl | The Dates Selected measure (table created if it does not exist) |
definition/model.tmdl | ref table entries and the PBI_QueryOrder annotation |
Optional helper expressions (--include-helpers): Year_Variable (current year + 2) and
TodayDate.
Ask for the PBIP path if it is not obvious from context. The script accepts the
.SemanticModel folder, its definition folder, the .pbip file, or the project root.
Before writing anything, check Power BI Desktop does not have the project open --
run pbir desktop list. If it does, tell the user to close it first; Desktop holds file
locks and will overwrite disk changes from its in-memory copy.
Do not guess these. Ask with AskUserQuestion unless the user already said:
--start 2021-01-01. For the end, either a fixed
--end yyyy-mm-dd (defaults to 31 Dec of the current year + 2) or --dynamic-end,
which ends at 31 Dec of Year_Variable so the table extends itself every year without
an edit. --dynamic-end adds the helper expressions automatically.
The range must cover every date in every fact table, with no gaps.7 (July -- Australian/NZ convention).
Use 1 for a calendar fiscal year, 4 for UK, 10 for US federal.--week-start 1 (default) numbers Monday as 1; 0 numbers Sunday as 0.python scripts/add_date_table.py --model "<path to project>" --dry-run
python scripts/add_date_table.py --model "<path to project>" --fy-start-month 7 --dynamic-end
Useful flags:
| Flag | Effect |
|---|---|
--table-name | Name the table something other than DimDate (the measure's DAX is rewritten to match) |
--measure-table | Put Dates Selected in an existing measure table instead of creating Measure Table |
--no-measure | Date table only |
--mark-as-date-table | Sets dataCategory: Time on the table and isKey on [Date] |
--include-helpers | Also add Year_Variable and TodayDate |
--holidays | An M list expression, e.g. "PublicHolidays[Date]", to populate IsHoliday / IsBusinessDay / Day Type |
--dry-run | Report what would change, write nothing |
The script is idempotent -- re-running it reports what is already present and leaves it
alone. Every lineageTag in the injected TMDL is regenerated, so the same assets can go
into any number of models without collisions.
The script does not create relationships -- it cannot know your fact tables. After it runs:
DimDate[Date], single
direction, many-to-one. Edit definition/relationships.tmdl directly (see the
pbip:tmdl skill) or let the user do it in Desktop.--mark-as-date-table. It is off by default because it is only correct once
[Date] is genuinely unique and contiguous, and because it disables Power BI's
auto date/time hierarchies for that column. Turn it on if the user wants DAX time
intelligence (DATESYTD, DATEADD) to work against this table.DimDate[Date] from report view only if a friendlier column is exposed --
report authors usually still need it for the axis.python ../../../pbip/skills/pbip/scripts/validate_pbip.py "<path to .pbip>"
Then have the user open the project in Power BI Desktop and refresh DimDate. The M
function runs entirely in memory -- there is no data source to authorize, so the refresh
should succeed with no credential prompt.
If --dynamic-end was used, confirm Year_Variable refreshes before DimDate; the
PBI_QueryOrder annotation the script writes puts it in the right order.
Dates Selected measureReturns a string describing whatever the date slicers currently select:
| Selection | Returns |
|---|---|
| Complete years | Selected Period: 2023 - 2025 |
| Non-adjacent years | Selected Period: 2021 | 2024 |
| Complete months in one year | Selected Period: Jan - Mar |
| Complete months across years | Selected Period: Nov 2023 - Feb 2024 |
| A single day | Selected Period: 14 Mar 2024 |
| A partial, non-contiguous range | Selected Period: a range of dates in Mar 2024 |
| Nothing resolvable | Selected Period: See Date Slicers |
Drop it in a card visual at the top of a page. Two strings near the top of the DAX are
meant to be edited: __PeriodPrefix (default "Selected Period: ") and __DiverseDates
(default "a range of dates in ").
It is coupled to the bundled DimDate. It reads [Date], [Year], [Start Of Month],
[Days in Year] and [Days In Month]. If you point it at a different date table, add
those columns first or rewrite the references.
IsHoliday is the string "Unknown", not a boolean, unless a holiday list was
passed via --holidays. IsBusinessDay still works (it tests <> true), but do not
write DAX assuming IsHoliday is boolean.ISO Year,
ISO Weeknumber and friends in its last step; the Week & Year / WeeknYear columns
carry the ISO logic instead. Do not reintroduce a newer upstream copy of the function
without re-applying the local modifications -- Dates Selected will break.FQuarternYear and FPeriodnYear are double, not int64. Harmless as sort keys,
but they show a general number format if you drag them onto a visual.Month Initial and Weekday Initial contain zero-width spaces (U+200B) as padding
so the twelve month initials stay distinct values. String comparisons against them
will not match a plain "J".pbip:tmdl skill, references/authoring-gotchas.md.references/column-reference.md -- all 58 columns, grouped, with the local
modifications vs. upstream listed at the end.assets/ -- the raw TMDL fragments, if you want to paste rather than run the script.assets/DatesSelected.measure.tmdl (opens in a new tab)assets/DimDate.tmdl (opens in a new tab)assets/FunctionDateTable.tmdl (opens in a new tab)assets/MeasureTable.tmdl (opens in a new tab)assets/helper-expressions.tmdl (opens in a new tab)references/column-reference.md (opens in a new tab)scripts/add_date_table.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub insightfulanalytics/pbi_agentic_dev --plugin semantic-models9 skills in this plugin
/dax-optimisationDAX performance optimization for semantic models. Automatically invoke when the user asks to "optimize DAX", "fix slow DAX", "DAX performance", "tune a measure", "debug a measure", "DAX anti-patterns", or mentions slow queries, server timings, or a visual that is slower than its DAX query./dax-standardHouse style for writing DAX measures. Build the rows a calculation needs into a table VAR, then aggregate, so each step can be debugged. Covers measure formatting (dynamic format strings, UDFs), the time-intelligence exception and recipes. Use to write, rewrite, review or format a measure, or for a DAX recipe. For a measurably slow measure, use `semantic-models:dax-optimisation`./lineage-analysisTrace relationships between semantic models and downstream reports across Fabric workspaces. Automatically invoke when the user asks to "find downstream reports", "show report lineage", "impact analysis", "what depends on this dataset", "cross-workspace lineage", "which reports are connected", "get model dependencies", or mentions model-to-report dependency tracing./model-changeThe end-to-end pipeline for changing a semantic model in a local PBIP, from confirming the field exists to proving the result against real data. Invoke on "change the model", "add a measure", "add a column", "the number is wrong", "add a relationship", "set up RLS", "add a calculation group", or any request that ends with a .tmdl file changing. Carries the Desktop-breaking gotchas./organize-semantic-modelOrganize a Power BI or Analysis Services semantic model end to end so it is ready for report authors, Excel users and Copilot - table groups, display folders, Title Case business names and naming conventions, hierarchies, sort-by columns, hiding, Analyze in Excel (IsAvailableInMDX), descriptions, format strings, data categories, context annotations, DAX formatting and UDFs, calculated-object justification, duplicate removal, perspectives, translations and security roles. Use whenever the user asks to "organize", "tidy", "clean up", "polish", "prepare", "standardize" or "make report-ready" a model or one table in it (for example "organize the date table"), to "fix naming conventions", "rename fields", "make names human readable" or "fix abbreviations", even when they name only one of these aspects, and whenever a model is driven through the Tabular Editor 3 MCP or the te CLI for that purpose. Not for DAX performance tuning (dax-optimisation skill) or model design and star-schema changes (semantic-model skill)./power-queryAuthor, validate, and test Power Query M expressions in semantic model partitions. Automatically invoke when the user mentions "Power Query", "M code", "M expression", "partition expression", "query folding", or asks to "write Power Query", "fix Power Query", "test a partition", "preview partition data", "debug Power Query step", "optimize Power Query", "format M code".Other plugins' skills for the same job