Coupler.io Blog

How to use Power BI All Except: Syntax, Examples, and Best Practices

Data filtering is crucial when you need to extract valuable insights from complex datasets. There are a couple of DAX filter functions that you can use but we’ll focus on Power BI All Except here. Let’s discover its syntax and show how to apply this function to your data. 

Let’s define: What is All Except in Power BI?

The All Except function lets you remove all context filters except for those that have been applied to specific columns. If you have an expression to evaluate, you can apply All Except to modify the filter context for the table and only calculate for the columns mentioned.

What is the difference between context filters and normal filters?

What are the function’s syntax and parameters?

Here’s the syntax for Power BI All Except:

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

The parameters of this function include:

Return Value

A table with all filters removed except for the filters on the specified columns.

Parameter Rules

What are other functions to remove filters in Power BI? 

SyntaxDescription
ALL(Table)Removes all filters from the specified table. It returns all the values but removes all context filters that may have been applied.
ALL(Column[, Column[,...]]) Removes all filters from specified columns but all other filters from other columns still apply. You can use it to remove filters from one or more columns within the same table.
REMOVEFILTERS(Table/Column)Removes all filters applied to the specified table or columns. It returns all values without any context filters.
REMOVEFILTERSALL(Column[, Column[,...]])Removes all filters applied to the specified columns while keeping filters on other columns intact.
CALCULATE(expression, REMOVEFILTERS(Column[, Column[,...]]))Calculates a result while temporarily removing filters from specified columns.
ALLSELECTED(Table/Column)Returns all values, ignoring any filters except for those applied by slicers or explicit filter functions like ALLSELECTED.
REMOVEFILTERSExcept(Table, Column[, Column[,...]])Removes filters from the specified table except for those applied to the specified columns.
REMOVEFILTERSALLEXCEPT(Table, Column[, Column[,...]])Removes filters from all columns except for the specified columns in the specified table.

How to perform advanced filtering with Power BI All Except?

To apply filters and hence remove them using the All Except DAX function, you need data. You can get the data to Power BI using the native connectors. However, they do not support most of the cloud services. In this case, you can use Coupler.io. It’s a reporting automation platform that lets you connect over 60 apps to Power BI including GA4, Google Search Console, advertising platforms, and so on. It also provides automatic data refresh that updates your dataset on a set schedule. 

To add data to Power BI with Coupler.io, select your data source in the form below and click Proceed

If you’re using Coupler.io for the first time, then create an account for free. After that, you need to:

With your data ready in Power BI, it’s quite easy and straightforward to apply the function. Here are the steps:

Or you can also locate it right under the Modeling tab.

Make sure to enter a name for your measure or column before writing the function. And remember that a DAX expression usually comes first before the All Except function. 

All Except Power BI use case examples 

Use case 1: Remove context filters on a sales dataset

Here’s a sales table with columns for product categories in different regions and their corresponding sales amounts. You can use All Except DAX to only perform calculations on columns mentioned within the function’s arguments and exclude all other columns. 

We’d like to analyze this dataset in a couple of ways. First, we can calculate the total sales amount for each product category. 

Total_Sales_Amount = SUM('Sales'[Sales Amount])

Next, we can add a filtered measure that evaluates whether the total sales amount for each product category exceeds the specified threshold. The FILTER DAX function applies a normal filter to the Product Category column to only include those categories where the total sales amount is greater than 3500. 

Total_Sales_Above_Threshold = CALCULATE ([Total_Sales_Amount], FILTER (VALUES ('Sales'[Product Category]), [Total_Sales_Amount] > 3500)

Lastly, we can create a measure that calculates average sales amounts across all regions but removes the context filters on all other columns. It modifies the filter context to only include the Region column and then calculates within that specified context.

Average Sales Amount = CALCULATE(AVERAGE('Sales'[Sales Amount]), ALLEXCEPT('Sales', 'Sales'[Region]))

This report shows the new measures respectively (left to right):

Use case 2: Remove context filters on an employee records dataset

Here is an Employee Records dataset for which we’ll make some examples of using the ALL Except function.

You can calculate the average employee salary for each department by preserving the context filter for the Department column. Here’s the formula: 

Average Salary per Department = CALCULATE (AVERAGE ('Employee_records'[Salary]), ALLEXCEPT ('Employee_records', 'Employee_records'[Department]))

The result:

Similarly, you can calculate the total number of employees in each department with:

Total Employees per Department = CALCULATE (COUNTROWS('Employee_records'), ALLEXCEPT ('Employee_records', 'Employee_records'[Department]))

The result: 

Note: When you create a new measure, it only adds a column to your table. Before you can use it for analysis, you need to add a visual such as a table, matrix, bar chart, etc. Then, you’d add the specified column(s) and the new measure to the visual for display.

What are the possible uses of the All Except function?

You can use it to calculate within a particular context: 

Best practices of Power BI All Except 

The function allows users to preserve context filters and improve data analysis. Let’s discuss some tips that can help you ensure its accuracy and efficiency.

Optimize selective data filtering in Power BI with All Except

Power BI All Except is a versatile function that allows you to control the filter context in your DAX calculations. It removes context filters on all other columns but preserves those on specified columns. This way, you can analyze precise data in complex and large datasets. 

This DAX function is often used within a CALCULATE function to evaluate an expression and also modify the filter context for the table. The first argument has to reference the base table, while subsequent arguments should be references to one or more base columns. Although you can use All Except in measures or calculated columns, it cannot be used in table expressions and column expressions. 

In Power BI, there are functions to work with filters, such as ALLSELECTED, KEEPFILTERS, REMOVEFILTERS, and the ALL function.

But before you can filter data, you need to import it into Power BI. Instead of doing this manually, use Coupler.io. It allows you to connect 60+ data sources to Power BI and schedule data refresh in your reports.

Connect your data sources to Power BI with Coupler.io

Get started for free
Exit mobile version