agentleFS
wardawgmalviciouswardawgmalvicious/agent-config/skills/powerbi/pbir-filters/SKILL.md

pbir-filters

Skill1 starsChanged 57 days agoMITView on GitHub

Use when authoring filter bodies in a Power BI PBIR report at report.json, page.json, or visual.json filterConfig.filters. Covers scopes (Report, Page, Visual — visual filter is sibling of `visual` NOT nested), filter types (Categorical, Advanced, TopN, VisualTopN, RelativeDate, RelativeTime, Tuple), filter body shape (Version 2, From[] aliases, Where[] using SourceRef.Source NEVER Entity), Categorical In / inverted Not-In with isInvertedSelectionMode, empty-default forms, Advanced Comparison with ComparisonKind 0-4, Between inclusive ranges, RelativeDate DateSpan/DateAdd with TimeUnit codes, TopN VisualTopN, And/Or/Not, doubled single quotes for strings, integer L / double D / datetime literal suffixes, hide/lock/single-select, filter-pane visible+expanded at report level (styling lives in theme).

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never hide visual-level filters — confuses users.

    line 262
  2. Very specific:

    Only visible and expanded live at report.json → objects.outspacePane.

    line 266

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PBIR Filters Reference

Filter Scopes

ScopeLocationApplies To
Reportreport.json → filterConfig.filters[]All pages and visuals
Pagepage.json → filterConfig.filters[]All visuals on the page
Visualvisual.json → filterConfig.filters[]That visual only (sibling of visual, not nested)

Filter Types

typeDescriptionUse Case
CategoricalIn / NotIn listYear, category, brand (most common)
AdvancedComparison on measures or columnsMeasure > threshold, ranges
TopNTop/bottom N by measureTop 10 customers
VisualTopNVisual-level TopNAuto-applied by some visuals
RelativeDateRolling date windowLast N days/months/years
RelativeTimeRolling time windowLast N hours/minutes
TupleMulti-column compositeRare

Filter Object Properties

PropertyTypeNotes
namestring20-char hex unique ID
displayNamestringOptional pane label
fieldobjectColumn or Measure reference (query projection syntax)
typestringSee table above
filterobjectWhere clause — optional when no defaults
isHiddenInViewModebooleanHide from pane in reading view
isLockedInViewModebooleanVisible but not editable
howCreatedstring"User" for user-created
ordinalintegerDisplay order (optional)
objectsobjectrequireSingleSelect, isInvertedSelectionMode

filter Body Shape

"filter": {
  "Version": 2,
  "From": [{"Name": "e", "Entity": "Exchange Rate", "Type": 0}],
  "Where": [{"Condition": {...}}]
}

Where clause rules:

  • From[] defines aliases
  • Conditions reference alias via "SourceRef": {"Source": "e"} — NOT Entity
  • String values: inner single quotes, doubled for escape: "'O''Brien'"
  • Integer values: L suffix ("2022L"); datetimes: "datetime'2024-01-01T00:00:00.0000000'"
  • Each value is wrapped in its own array: [[{val1}], [{val2}]]

Categorical — In (Multi-Select Default)

{
  "name": "d3f20cea05c37b47123a",
  "field": {"Column": {"Expression": {"SourceRef": {"Entity": "Exchange Rate"}}, "Property": "From Currency"}},
  "type": "Categorical",
  "filter": {
    "Version": 2,
    "From": [{"Name": "e", "Entity": "Exchange Rate", "Type": 0}],
    "Where": [{"Condition": {"In": {
      "Expressions": [{"Column": {"Expression": {"SourceRef": {"Source": "e"}}, "Property": "From Currency"}}],
      "Values": [
        [{"Literal": {"Value": "'EUR'"}}],
        [{"Literal": {"Value": "'USD'"}}]
      ]
    }}}]
  }
}

Categorical — Inverted (Not In)

Wrap In with Not AND set isInvertedSelectionMode: true.

"Where": [{"Condition": {"Not": {"Expression": {"In": {
  "Expressions": [{"Column": {"Expression": {"SourceRef": {"Source": "b"}}, "Property": "Brand"}}],
  "Values": [[{"Literal": {"Value": "'ASAN'"}}]]
}}}}}],
"objects": {"general": [{"properties": {
  "isInvertedSelectionMode": {"expr": {"Literal": {"Value": "true"}}}
}}]}

No Default (Empty Filter)

Omit filter entirely, OR include with empty Where:

"filter": {"Version": 2, "From": [{"Name": "d", "Entity": "Date", "Type": 0}], "Where": []}

Advanced — Comparison

{
  "name": "1c9a23490ebe5441b781",
  "field": {"Measure": {"Expression": {"SourceRef": {"Entity": "Budget"}}, "Property": "Budget vs. Turnover (%)"}},
  "type": "Advanced",
  "filter": {
    "Version": 2,
    "From": [{"Name": "d", "Entity": "Budget", "Type": 0}],
    "Where": [{"Condition": {"Comparison": {
      "ComparisonKind": 1,
      "Left": {"Measure": {"Expression": {"SourceRef": {"Source": "d"}}, "Property": "Budget vs. Turnover (%)"}},
      "Right": {"Literal": {"Value": "0D"}}
    }}}]
  }
}

ComparisonKind Codes

0=Equal, 1=GreaterThan, 2=GreaterThanOrEqual, 3=LessThanOrEqual, 4=LessThan.

Between (Range, Inclusive)

"Where": [{"Condition": {"Between": {
  "Expression": {"Column": {"Expression": {"SourceRef": {"Source": "d"}}, "Property": "Date"}},
  "LowerBound": {"Literal": {"Value": "datetime'2024-01-01T00:00:00.0000000'"}},
  "UpperBound": {"Literal": {"Value": "datetime'2024-12-31T00:00:00.0000000'"}}
}}}]

RelativeDate — DateSpan / DateAdd

TimeUnit codes: 0=Day, 1=Week, 2=Month, 3=Year, 4=Decade, 5=Second, 6=Minute, 7=Hour.

Current period start:

"Right": {"DateSpan": {"Expression": {"Now": {}}, "TimeUnit": 2}}

3 months ago from start of current month:

"Right": {"DateAdd": {
  "Expression": {"DateSpan": {"Expression": {"Now": {}}, "TimeUnit": 2}},
  "TimeUnit": 2,
  "Amount": -3
}}

RelativeTime uses the same shape with TimeUnit 5/6/7.

TopN

The ranking subquery must be declared as a From source ("Type": 2) and referenced by alias from In.Table.SourceRef — the only shape Desktop serializes (verified against microsoft/BCApps PBIR sources + live repro, 2026-08). Do not inline the Subquery under In.Table, and do not author a bare VisualTopN condition: those forms pass PBIR schema validation but the filter matches nothing (the visual renders empty) and the service editor freezes on save-edits trying to rebuild the filter card from it.

"type": "TopN",
"filter": {
  "Version": 2,
  "From": [
    {"Name": "subquery", "Expression": {"Subquery": {"Query": {
      "Version": 2,
      "From": [
        {"Name": "c", "Entity": "Customer", "Type": 0},
        {"Name": "s", "Entity": "Sales", "Type": 0}
      ],
      "Select": [{"Column": {"Expression": {"SourceRef": {"Source": "c"}}, "Property": "Customer Name"}, "Name": "field"}],
      "OrderBy": [{"Direction": 2, "Expression": {"Measure": {"Expression": {"SourceRef": {"Source": "s"}}, "Property": "Revenue"}}}],
      "Top": 10
    }}}, "Type": 2},
    {"Name": "c", "Entity": "Customer", "Type": 0}
  ],
  "Where": [{"Condition": {"In": {
    "Expressions": [{"Column": {"Expression": {"SourceRef": {"Source": "c"}}, "Property": "Customer Name"}}],
    "Table": {"SourceRef": {"Source": "subquery"}}
  }}}]
}

OrderBy Direction: 2 = descending (Top N); 1 = ascending (Bottom N). Desktop emits Select[].Name as the literal "field". The subquery evaluates inside the visual's filter context, so page/report filters and slicers scope the ranking.

Compound — And / Or

"Condition": {"And": {
  "Left":  {"Comparison": {"ComparisonKind": 2, "Left": {...}, "Right": {...}}},
  "Right": {"Comparison": {"ComparisonKind": 3, "Left": {...}, "Right": {...}}}
}}

Condition Reference

ConditionDescription
InValue in list
Not → InValue NOT in list
ComparisonSingle comparison
BetweenInclusive range
And / OrCompound
NotNegation wrapper
ContainsString contains
StartsWithString prefix
DateSpanRelative period
DateAddOffset date expression
In + Subquery From sourceTop/bottom N — see TopN section; never author a bare VisualTopN condition
NowCurrent datetime — inside DateSpan/DateAdd

Contains / StartsWith — Minimal Shape

"Where": [{"Condition": {"Contains": {
  "Left":  {"Column": {"Expression": {"SourceRef": {"Source": "c"}}, "Property": "Customer Name"}},
  "Right": {"Literal": {"Value": "'Acme'"}}
}}}]

StartsWith uses the same shape — swap Contains for StartsWith.

Hide / Lock / Single-Select

OptionEffect
isHiddenInViewMode: trueHidden from filter pane in reading view
isLockedInViewMode: trueVisible but not editable
objects.general.properties.requireSingleSelectForce exactly one value

Common combinations:

Use CaseHiddenLockedSingleSelect
Hidden background filtertruetrue–
Locked parameterfalsetruetrue
Normal multi-selectfalsefalsefalse
Visible single-selectfalsefalsetrue

Never hide visual-level filters — confuses users. Only hide report/page filters with justification.

Filter Pane Visibility — outspacePane on report.json (owned here)

Only visible and expanded live at report.json → objects.outspacePane. All styling (colors, text, backgrounds, input box, width) belongs in the theme — see pbir-themes.

"objects": {"outspacePane": [{"properties": {
  "visible":  {"expr": {"Literal": {"Value": "true"}}},
  "expanded": {"expr": {"Literal": {"Value": "false"}}}
}}]}

Discovering Filter Values

pbir model "Report.Report" -d                                                   # dump model
pbir model "Report.Report" -d -t Date                                           # single table
pbir model "Report.Report" -q "EVALUATE DISTINCT('Date'[Calendar Year (ie 2021)])"

Gotchas

IssueCauseFix
Filter silently ignoredSourceRef.Entity in Where instead of SourceRef.SourceReference alias defined in From[]
Top-N visual empty AND service editor freezes on saveSubquery inlined in In.Table (or bare VisualTopN) — schema-valid but not engine-validDeclare subquery as a From source (Type: 2), reference via In.Table.SourceRef — see TopN section
"Cleanup" report-level filter silently shrinks totalsReport filters remove matching rows from every visual, not just from slicers/legendsQuantify the excluded members' measure impact first (DAX); scope cosmetic exclusions to the slicer/visual level
Filter values not selectedValues not double-wrappedEach value is its own array: [[{v1}], [{v2}]]
Deploy error on report filter pane stylingStyling in report.json outspacePaneMove to theme visualStyles["*"]["*"].outspacePane
Inverted filter still shows selected valuesMissing isInvertedSelectionMode: trueSet it alongside the Not→In Where
RelativeDate rolling window off by oneMissing DateAdd offsetWrap DateSpan in DateAdd with negative Amount
String literal with apostrophe failsUnescaped single quoteDouble it: "'O''Brien'"
Integer filter value rejectedUsed D suffixIntegers use L
DateTime filter rejectedMissing trailing '"datetime'YYYY-MM-DDTHH:MM:SS.0000000'"
filterConfig in wrong place on visualNested inside visualSibling of visual at root of visual.json
Empty-filter default values appearPrevious Where clause presentUse "Where": [] or omit filter entirely
Visual filter hidden causes UX confusionisHiddenInViewMode on visual scopeDon't hide visual-level filters

Reference

See also

  • pbir-visual-json — visual.json filterConfig placement (sibling of visual)
  • pbir-themes — filter pane and filter card styling
  • pbir-bookmarks — byExpr filter snapshots (same SQExpr shape)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.