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.

ALLEXCEPT( <table>, <column>, [<column> …] )

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.

This is a reproduction of the Power BI interface for teaching purposes. It differs from the real interface.

Tip

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:

City Revenue = CALCULATE( [Revenue], ALLEXCEPT( Customers, Customers[City] ) )
Power BI accepts this DAX foryes, Measureyes, Calculated columnno, Calculated tableno, Virtual table
In plain words

“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.

Table visual, The city revenue of each customer
CityNameCity Revenue
New YorkOrvane900,000
New YorkKumora900,000
New YorkTalvio900,000
ChicagoRibelia500,000
ChicagoMovara500,000
TorontoNorthel300,000
TorontoSam Lee300,000
Total1,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.

  1. 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
    ClassStudentPoints
    6AAlma14
    6ABilal10
    6BChloé12

    Which formula should you write for “Class Points”?

  2. 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
    ShopProductLoaves
    DowntownBaguette300
    DowntownRye100
    StationBaguette200

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.