11.4ALLEXCEPT
Sometimes you will want CALCULATE to replace the filters of almost every column of a table, except one. ALLEXCEPT supplies the table it needs, in a single function.
11.4.1Everything except one column
ALLEXCEPT returns a table with all the columns of a table, except those you name. Like ALL, it ignores the filters.
With Customers and Customers[City], its table has three columns, Customer ID, Name and Type, and the seven customers. The city is not in it.
| Customers[Customer ID] | Customers[Name] | Customers[Type] | |
|---|---|---|---|
| 1 | C001 | Orvane | Company |
| 2 | C002 | Kumora | Company |
| 3 | C003 | Talvio | Company |
| 4 | C004 | Ribelia | Company |
| 5 | C005 | Movara | Company |
| 6 | C006 | Northel | Company |
| 7 | C007 | Sam Lee | Individual |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
ALLEXCEPT is handy when the table has many columns. To keep only the city, you name a single column, instead of writing all the others.
Take a table visual with the City and Name columns, and this measure:
“For each customer, I want the revenue of all the customers in their city, keeping only the city.”
On the Orvane row, the context filters New York and Orvane. CALCULATE replaces the filter of the name with the table from ALLEXCEPT, which contains the seven customers. The city is not in this table, so the New York filter stays. The measure returns 900,000, the revenue of New York.
| City | Name | City Revenue |
|---|---|---|
| New York | Orvane | 900,000 |
| New York | Kumora | 900,000 |
| New York | Talvio | 900,000 |
| Chicago | Ribelia | 500,000 |
| Chicago | Movara | 500,000 |
| Toronto | Northel | 300,000 |
| Toronto | Sam Lee | 300,000 |
| Total | 1,700,000 |
This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.
Practice
Each exercise is solved with the function you just discovered. Two exercises per function, a direct use and a combined use, from easiest to hardest, on data other than the course data. Pick the right formula out of five.
Direct useMeasureDifficulty
A school already has a “Total Points” measure, the sum of the “Points” column of the “Grades” table. A visual shows the “Class” and “Student” columns. Write the “Class Points” measure, which returns for each student the total points of their whole class.
Grades Class Student Points 6A Alma 14 6A Bilal 10 6B Chloé 12 Which formula should you write for “Class Points”?
Combined useMeasureDifficulty
A bakery has two shops. It already has a “Loaves” measure, the sum of the “Loaves” column of the “Batches” table. A visual shows the “Shop” and “Product” columns. Write the “Share within Shop” measure, the loaves of the product divided by the loaves of its whole shop.
Batches Shop Product Loaves Downtown Baguette 300 Downtown Rye 100 Station Baguette 200
The rest of this lesson is part of izyDAX Pro
You have just read the first section. The next 3, their animations, the exercises and the summary are waiting for you with izyDAX Pro, in a single payment.