Ravindra BagaleCourses & study guides मराठी Track your progress

13. DAX: Data Analysis Expressions

13.10 ALL, ALLEXCEPT, REMOVEFILTERS and ALLSELECTED in Power BI with Example

ALL and % of total in Power BI with example — in 30 seconds

What: ALL removes filters from a column or table inside CALCULATE.

Why: % of total needs the grand total in every row. Each row normally sees only its own city.

Tiny example: Pune ₹1,200 ÷ ₹1,500 = 80%. Nashik ₹300 ÷ ₹1,500 = 20%.

First look at the data (before → after):

ALL and % of total in Power BI with example: before and after tables, fictional Blinkit Maharashtra data

Same before / after tables as text

Before — Total Sales by City

City Total Sales
Pune ₹1,200
Nashik ₹300
Total ₹1,500

About this data: This table uses columns: City, Total Sales. This table uses columns: City, Total Sales, All City Sales, % of Total. This table uses columns: Function, Removes filters from, Can return a table?. Values shown are the lesson examples already on this page (not a new dataset).

Formula / click path

All City Sales = CALCULATE([Total Sales], ALL(Orders[City]))
% of Total = DIVIDE([Total Sales], [All City Sales])

After — Matrix with % of Total

City Total Sales All City Sales % of Total
Pune ₹1,200 ₹1,500 80%
Nashik ₹300 ₹1,500 20%
Total ₹1,500 ₹1,500 100%

Do it step by step:

  1. New measure: All City Sales with ALL on the City column you put in the matrix.
  2. New measure: % of Total with DIVIDE.
  3. Format % of Total as Percentage.
  4. Add both to the matrix. Check 80% and 20%.
  5. Want % of what the slicer selected? Use ALLSELECTED instead (see the guide on % of total).

These remove filters – essential for percentage-of-total calculations.

All Category Sales = CALCULATE([Total Sales], ALL(Product))

% of All Categories = DIVIDE([Total Sales], [All Category Sales])

-- Share of a product within its category (keeps only the Category filter)
% of Category =
DIVIDE(
    [Total Sales],
    CALCULATE([Total Sales], ALLEXCEPT(Product, Product[Category]))
)

-- Share of a dark store within its city
% of City Orders =
DIVIDE(
    [Total Orders],
    CALCULATE([Total Orders], ALLEXCEPT(DarkStore, DarkStore[City]))
)

-- REMOVEFILTERS: same effect as ALL when used as a CALCULATE filter, clearer name
Orders All Cities = CALCULATE([Total Orders], REMOVEFILTERS(DarkStore))

-- Percentage of what the user has currently selected in slicers
% of Selected Total =
DIVIDE([Total Sales], CALCULATE([Total Sales], ALLSELECTED(Product)))
Function Removes filters from Can return a table?
ALL(Table) / ALL(Column, …) The table / listed columns Yes
ALLEXCEPT(Table, Col1, …) All columns of the table except the listed ones Yes
REMOVEFILTERS(Table or Column) Same as ALL, but only as a CALCULATE modifier No
ALLSELECTED(…) Filters from the visual, but keeps outer filters (slicers, filters pane) Yes

ALL, ALLSELECTED and ALLEXCEPT – interviewers always ask about these three. Test them in a table visual and see the difference yourself.

Ravindra Bagale's Tip

Friends, many students use ALL(Table) when they only meant to ignore one column, so the measure also ignores every other slicer. Remove filters from the smallest scope you need: ALL(DarkStore[City]) or ALLSELECTED for "% of selected". Test the measure with two slicers selected before trusting it. Don't worry – after doing it two or three times, it becomes a habit.

Loading DAX practice tasks...

  1. City % of total (Easy): Row per Store City. Write City % = [Total Sales] ÷ sales for all cities.
  2. Grand total under a slicer (Easy): Slicer: City = Mumbai. Write All Cities = [Total Sales] for all cities.
  3. REMOVEFILTERS on a table (Easy): Row per Product Category. Write All Product Sales = [Total Sales] with all Product filters removed.
  4. City total next to each store (Medium): A matrix shows Store City and then StoreName. Write City Total = [Total Sales] for the whole city of that store.
  5. Store share within its city (Medium): A matrix shows Store City and then StoreName. Write Store % of City = [Total Sales] ÷ city total.
  6. Share of the selection (Medium): Slicer: City = Pune and Mumbai. Row per Store City. Write Share of Selected = [Total Sales] ÷ sales of the selected cities.
  7. Platform share of orders (Medium): Row per Orders Platform. Write Platform % = [Total Orders] ÷ orders of all platforms.
  8. ALL as a table (Hard): Slicer: Category = Dairy. Write Product Count = number of rows in ALL of the Product table.
  9. Count categories (Hard): Write Category Count = number of rows in ALL of Product[Category].
  10. Qty ignoring every slicer (Hard): Slicers: City = Pune and Platform = Zepto. Write Total Qty All = [Total Qty] with ALL on Orders.

Ravi Sir's Cards for this lesson

मराठी cards