ALLSELECTED DAX Function (Filter)
Returns all the rows in a table, or all the values in a column, ignoring any filters that might have been applied inside the query, but keeping filters that come from outside.
Syntax
Parameter | Attributes | Description |
---|---|---|
TableNameOrColumnName | Optional |
Remove all filters on the specified table or column applied within the query. |
ColumnName | Optional Repeatable |
A column in the same base table. |
Return values
Remarks
This function removes the corresponding filters from the filter context, restoring the last shadow filter context. It does not materialize the resulting table when called directly in a filter argument of CALCULATE or CALCULATETABLE .
ALLSELECTED can be used as a table expression when it has at least one argument.
ALLSELECTED without arguments can be used only as a CALCULATE or CALCULATETABLE modifier and removes all the filters from the filter context.
ALLSELECTED supports multiple columns as argument since May 2019.
In former versions this syntax is equivalent of ALLSELECTED ( table[column1], table[column2] ):
SUMMARIZE ( ALLSELECTED ( table ), table[column1], tabls[column2] )
» 3 related functions
Examples
ALLSELECTED is typically used as a CALCULATE modifier.
CALCULATE ( ..., ALLSELECTED () ) CALCULATE ( ..., ALLSELECTED ( table ) ) CALCULATE ( ..., ALLSELECTED ( table[column] ) )
ALLSELECTED can be used as a table function, even though it is not a best practice.
EVALUATE CALCULATETABLE ( { COUNTROWS ( ALLSELECTED ( Product ) ) }, Product[Category] = "Audio" )
Be aware that using ALLSELECTED in an iterator could produce unintuitive results.
EVALUATE CALCULATETABLE ( ADDCOLUMNS ( ALL ( 'Product'[Category] ), "Sales Amount", [Sales Amount], "Sales Sel", CALCULATE ( [Sales Amount], ALLSELECTED ( Product[Category] ) ) ), Product[Category] IN { "Audio", "Computer" } )
Product[Category] | Sales Amount | Sales Sel |
---|---|---|
Audio | 384,518.16 | 30,591,343.98 |
TV and Video | 4,392,768.29 | 30,591,343.98 |
Computers | 6,741,548.73 | 30,591,343.98 |
Cameras and camcorders | 7,192,581.95 | 30,591,343.98 |
Cell phones | 1,604,610.26 | 30,591,343.98 |
Music, Movies and Audio Books | 314,206.74 | 30,591,343.98 |
Games and Toys | 360,652.81 | 30,591,343.98 |
Home Appliances | 9,600,457.04 | 30,591,343.98 |
Related articles
Learn more about ALLSELECTED in the following articles:
-
The definitive guide to ALLSELECTED
ALLSELECTED is a powerful function that can hide several traps. This article is an in-depth analysis of the behavior of ALLSELECTED, explaining shadow filter contexts, what they are and how they are used by ALLSELECTED. » Read more
-
Managing “all” functions in DAX: ALL, ALLSELECTED, ALLNOBLANKROW, ALLEXCEPT
This article provides a complete explanation of the behavior of the ALLxxx functions in DAX. When used as filters in CALCULATE, ALLxxx functions might display unexpected behaviors. » Read more
-
Computing same product sales in DAX
This article shows a technique in DAX to compute the sales volume of products that were available right from the beginning of a selected time period, ignoring products introduced afterwards. » Read more
-
Filtering the Top 3 products for each category in Power BI
This article describes different techniques to display the first three products for each category in Power BI. It includes considerations on how to adapt the technique to different models and requirements. » Read more
-
Introducing RANKX in DAX
RANKX is a simple function used to rank a value within a list of values. Its use is simple, but it can be a source of frustration for newbies. In this article we introduce the RANKX function with a few examples. » Read more
-
Introducing ALLSELECTED in DAX
ALLSELECTED is an extremely complex function to use in DAX. In this article, we provide an introduction to ALLSELECTED and its main use cases, leaving the most intricate details to more advanced articles. » Read more
-
Using ALLSELECTED in composite models
Using ALLSELECTED with no arguments in a remote model later used in a composite model might produce unexpected results. In this article we examine the topic and provide the reasons why ALLSELECTED requires special attention. » Read more
Related functions
Other related functions are:
Last update: Nov 7, 2024 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo, John Mayer
Microsoft documentation: https://docs.microsoft.com/en-us/dax/allselected-function-dax