Visualize and analyze the data · Topic 2 of 6
Slicers, Filters and Visual Calculations
PL-300 slicing and filtering: use slicers and the filters pane at visual, page and report level, and write visual calculations such as running sum.
- 5 min
- Slicers filter the page. The Filters pane works at visual, page and all pages levels.
- Filter types are basic, advanced, Top N, relative date and relative time.
- A visual calculation is DAX on one visual and is not stored in the model.
What it is
Readers narrow data with slicers on the canvas and with filters in the Filters pane. Authors choose between them based on who needs control. Visual calculations are a newer feature: DAX written directly on a visual, using only the data in that visual, for things like running totals and percent of parent.
How it works
Slicers
A slicer is a visual that filters other visuals on the page. Types depend on the field.
| Field type | Slicer style |
|---|---|
| Text or category | List, Dropdown, Tile (buttons) |
| Number | Between (range), less than or equal, greater than or equal |
| Date | Between (calendar), Relative date such as last 30 days, Relative time |
| Hierarchy | A slicer with several fields |
Settings include single select or multi select, Select all, a search box and a Slicer header. A slicer filters every visual on the page by default. You can stop a slicer affecting a visual with Edit interactions, and apply a slicer to other pages with Sync slicers, both covered later.
The Filters pane
The pane has three levels.
| Level | Applies to |
|---|---|
| Filters on this visual | The selected visual only |
| Filters on this page | Every visual on the page |
| Filters on all pages | Every page in the report |
Filter types are Basic (tick values), Advanced (conditions such as contains or starts with, with And or Or), Top N (top or bottom items by a measure), Relative date and Relative time. Filters can be locked or hidden by the author, so readers cannot change them.
Slicer or filter? A slicer is visible and designed for readers to interact with. A filter in the pane is suited to fixed conditions the author sets, such as excluding test data, and to filters that readers rarely change. Page level filters and slicers combine with each other, and all must be satisfied.
Visual calculations
A visual calculation is a DAX expression defined and run on a visual, not stored in the model. It refers to what is in the visual: columns, measures or other visual calculations. Because it works on the aggregated rows already in the visual, it is often simpler and faster than an equivalent measure.
To add one, select the visual and choose New calculation, which opens Edit mode with a preview, a formula bar and a visual matrix. After you save it, it appears as a field in the visual.
Running sum = RUNNINGSUM ( [Sales Amount] )
Moving average = MOVINGAVERAGE ( [Sales Amount], 3 )
Percent of parent = DIVIDE ( [Sales Amount], COLLAPSE ( [Sales Amount], ROWS ) )
Versus previous = [Sales Amount] - PREVIOUS ( [Sales Amount] )
| Function | Purpose |
|---|---|
| RUNNINGSUM, MOVINGAVERAGE | Running total and moving average along an axis |
| PREVIOUS, NEXT, FIRST, LAST | Refer to another row of the visual |
| COLLAPSE, COLLAPSEALL | Evaluate at a higher level, for percent of parent and of total |
| EXPAND, EXPANDALL | Evaluate at a lower level |
| LOOKUP, LOOKUPWITHTOTALS | Find a value by matching a column |
Many have optional Axis (ROWS or COLUMNS, and so on) and Reset parameters. The axis sets the direction of travel across the visual, and reset restarts a running calculation, for example each year. Templates such as Running sum, Moving average and Percent of parent write the formula for you.
Rules to remember:
- A visual calculation can use only fields in the visual. Add the field first, and hide it if you do not want it displayed.
- It cannot use functions that need model relationships, such as USERELATIONSHIP, RELATED and RELATEDTABLE.
- It is not reusable across visuals, cannot be pinned to a dashboard and does not work in some visuals such as slicers and the Key influencers visual.
- It is not part of the model, so other reports cannot see it.
Visual calculation or measure
| Need | Choose |
|---|---|
| A running total or moving average in one visual | Visual calculation |
| A value reused in many visuals, reports or by other authors | Measure in the model |
| A calculation using relationships or filter context changes | Measure |
A worked scenario
An author wants a column chart of monthly sales with a line showing the running total for the year. She selects the visual, uses the Running sum template on Sales Amount with Reset to the year, and hides nothing. Another visual needs the sales share of each category within its department, so she uses Percent of parent with COLLAPSE. A measure for gross margin is used on many pages, so she writes that one in the model.
What to remember for the exam
- Slicers filter the page. The Filters pane works at visual, page and all pages levels.
- Filter types are basic, advanced, Top N, relative date and relative time.
- A visual calculation is DAX on one visual and is not stored in the model.
- RUNNINGSUM, MOVINGAVERAGE, PREVIOUS, NEXT, FIRST, LAST, COLLAPSE and EXPAND are visual calculation functions.
- A visual calculation can only use fields on the visual, and is not reusable.
If a question needs a calculation reused across reports, the answer is a model measure, not a visual calculation.
How the exam asks about this
- "A running total shown in a single chart, without changing the model." Visual calculation.
- "Show only the top 10 products." Top N filter.
- "Show data for the last 30 days, updating daily." Relative date slicer or filter.
- "Readers must not change a filter." Lock the filter in the Filters pane.
Common mistakes
Putting a visual calculation where a reusable measure is needed.
Using a filter pane filter when readers need control.
Forgetting to add the field to the visual first.
Expecting slicers to apply to other pages without sync.
Check yourself
Where is a visual calculation stored?
On the visual, not in the semantic model.
Which filter type shows the top five products by sales?
Top N.
Which function gives a running total in a visual calculation?
RUNNINGSUM.
Topic 2 of 6 in Visualize and analyze the data
Test yourself on Visualize and analyze the data
The full Microsoft PL-300 question bank has 657 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Microsoft. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.