Controlling Overwrites: KEEPFILTERS vs Standard CALCULATE
Overview & Learning Objectives
While `ALL()` clears every filter to return the absolute database grand total, users rarely want that. Usually, a user filters a slicer to "North & South Zones" and expects the visual matrix to sum to 100% of those selected zones! `ALLSELECTED()` ignores filters inside the visual rows while respecting all external slicers chosen by the user.
- Master the behavior of `ALLSELECTED()` inside visual matrixes and bar charts.
- Contrast `ALL()` (absolute grand total) with `ALLSELECTED()` (filtered visual total).
- Build bulletproof "% of Selected Slices" measures that always sum to exactly 100%.
Industry Standard
Standard: Enterprise dashboard design at Flipkart and Deloitte requires category contribution matrixes to use `ALLSELECTED()` so rows recalculate to 100% when users filter by region or date.
Real-World Example: Burger Point Regional Distribution
Burger Point management filters an outer slicer to 2 cities: Mumbai and Pune. The visual matrix shows sales by outlet in those two cities.
| Outlet Name | City | Sales (₹) | % using ALL() (All 50 Cities) | % using ALLSELECTED() (Mumbai+Pune) |
|---|---|---|---|---|
| Bandra Burger | Mumbai | 60,000 | 1.2% (Diluted by 50 cities) | 40.0% (Sums to 100% of selection) |
| FC Road Burger | Pune | 90,000 | 1.8% (Diluted by 50 cities) | 60.0% (Sums to 100% of selection) |
Syntax & Core Workflow
% of Selected Total =
VAR CurrentSales = [Total Sales]
VAR SelectedTotal = CALCULATE([Total Sales], ALLSELECTED(Dim_Store))
RETURN
DIVIDE(CurrentSales, SelectedTotal)
Parameters Breakdown
ALLSELECTED(): Restores the filter context as it existed outside the current visual, ignoring visual row/column grouping.Dynamic Denominator: The denominator adjusts dynamically whenever the user changes an external slicer.100% Total Guarantee: The sum of all visible rows in the visual table will always equal exactly 100%.
Sample Walkthrough (Q&A)
Question: Why does % of Total using ALL() fail to sum to 100% when an outer slicer is active?
Formula / Action: ALL() ignores the outer slicer and uses the entire global database sales as the denominator.
Result: The visible rows only sum to a fraction (e.g. 15%), confusing business executives.
Explanation: `ALL()` removes all filters including the slicer. `ALLSELECTED()` keeps the slicer and only clears the visual row headers.
Common Mistakes & Limitations
- Using `ALL()` when business stakeholders requested a dynamic "% of Selected" contribution metric.
- Nesting multiple complex `ALLSELECTED()` statements inside iterators, which can lead to the infamous "ALLSELECTED shadow context" bug.
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Quick Measure: % of Category Total | Quick Measure -> Mathematical -> % of Category | Quick Measure |
| Format Output | Measure Tools -> Percentage (0.0%) | Percentage |
Pro Tips & Modern Alternatives
- Pass specific column parameters to `ALLSELECTED(Table[Column])` to clear only specific visual grouping dimensions.
- Check your totals in visual matrices: the total row for an `ALLSELECTED` percentage measure should always display 100.0%.