Dax Function: ALLEXCEPT
Category: Filter Functions
ALLEXCEPT is a Data Analysis Expressions (DAX) function in Power BI that removes filters from all columns in a table, except for those explicitly specified. It enables selective filtering, maintaining specific columns’ filter context while clearing others.
Purpose
The ALLEXCEPT function is used to:
Create measures that ignore most filters but honor specific ones.
Provide precise control over filter contexts in calculations.
Enable focused aggregations or comparisons by maintaining only relevant filters.
Type of Calculations
The function is often used for:
Dynamic aggregations.
Calculations requiring selective filter retention.
Percentage of total or subtotal calculations where some filters are preserved.
Practical Use Cases
Selective Totals: Calculate totals based on specific filters while ignoring others.
Dynamic Reporting: Enable drill-down reports by maintaining filter context for key dimensions.
Custom Measures: Create measures that operate within specific filters.
ALLEXCEPT(<table>, <column1>, [<column2>, ...])</column2></column1></table>
| Parameter | Type | Description |
|---|---|---|
table | Table | The table containing the columns for which filters are cleared. |
column1 | Column | The column for which filters are retained. |
[column2, ...] | Column(s) | Additional columns for which filters are retained. |
How Does ALLEXCEPT Dax Works
The ALLEXCEPT function:
Removes all filters applied to a table.
Retains filters on the specified columns.
Evaluates expressions using the modified filter context.
Example Formula:
Selective Sales =
CALCULATE(
SUM(Sales[Amount]),
ALLEXCEPT(Sales, Sales[Region])
)
Here, filters on Sales[Region] are retained, while others (e.g., date, product) are removed.
What Does It Return?
The function returns:
Table: A version of the input table where all filters are removed, except for the specified columns.
When Should We Use It?
Selective Aggregations: When calculations need to respect filters on certain dimensions.
Creating Measures: For percentage calculations where some filters need to remain active.
Custom Visuals: Build visuals that respond only to specific filters.
Examples
Basic Usage :
ALLEXCEPT(Sales, Sales[Region])
Clears all filters on the Sales table, except for the Region column.
Column Usage
Region Sales =
CALCULATE(
SUM(Sales[Amount]),
ALLEXCEPT(Sales, Sales[Region])
)
Computes total sales while retaining region-specific filters.
Advanced Usage
Percentage of Region Sales =
DIVIDE(
SUM(Sales[Amount]),
CALCULATE(SUM(Sales[Amount]), ALLEXCEPT(Sales, Sales[Region]))
)
Calculates the percentage contribution of sales for each region to the total.
Tips and Tricks
Use for Drill-Down Reports: Maintain key filters while clearing unrelated ones for specific measures.
Combine with CALCULATE: Leverage
CALCULATEto dynamically manage filter contexts.Beware of Overuse: Applying too many exceptions can complicate the model and affect performance.
Performance Impact of ALLEXCEPT DAX Function:
Avoid using ALLEXCEPT on large tables with many exceptions, as this can lead to slow performance.
Optimize by targeting only necessary columns.
Related Functions You Might Need
ALL: Removes all filters from a table or column.
ALLSELECTED: Considers filters applied in a visual context.
REMOVEFILTERS: Explicitly removes filters from specified columns or tables.
Want to Learn More?
For more information, check out the official Microsoft documentation for ALLEXCEPT You can also experiment with this function in your Power BI reports to explore its capabilities.
Unlock the full capabilities of Power BI and elevate your data insights with our specialized consulting services. Whether you need guidance on advanced DAX functions like those highlighted here, support in designing interactive dashboards, or expertise in optimizing data models for enhanced performance, our experienced Power BI consultants are equipped to deliver customized solutions for your business. Explore our Power BI Consulting Services page to discover how we can help your organization make smarter, data-driven decisions.
It removes filters from all columns in a table, except for the ones specified.
Use it for calculations requiring selective filter retention, like drill-down aggregations.
ALL removes all filters, while ALLEXCEPT retains filters for specified columns.
Yes, you can specify multiple columns for which filters will be retained.
It can be if applied to large datasets with many exceptions. Use it judiciously.