How to Use ALLSELECTED in Power BI
Ever create a clever Power BI metric, add it to a visual, and then watch it break the moment you use a slicer? You're likely trying to calculate something like a "percentage of total," but the "total" doesn't update when you filter your view. This is a classic Power BI challenge that stumps new and experienced users alike, and the solution lies in a powerful DAX function: ALLSELECTED. This article will break down exactly what ALLSELECTED does, how it differs from its cousin ALL, and show you practical, step-by-step examples of how to use it to create dynamic, interactive reports.
Understanding the Foundation: Filter Context in Power BI
Before analyzing ALLSELECTED in detail, we have to talk about its environment: the filter context. Think of filter context as the set of "active" filters applied to your data at any given time. These filters can come from anywhere:
- Slicers: A user selecting "2023" in a year slicer.
- Other visuals on the page: Clicking a bar in one chart to filter another.
- The visual itself: Rows or columns in a table, for instance, a row with Product Brand="Nike."
- Filters pane: Filters you manually place on the visual, a report, or the entire page.
Every calculation you write in DAX operates within a filter context. For example, if you are looking at your total sales in a table sliced with "Product category," the filter context for the "Electronics" row is "showing the sales for products only in this category." Most DAX formulas respect the active filter context implicitly. Yet, the real power of analytics is in altering this context to ask different questions such as "What would be the percentage of total sales overall?" For that, you should use special DAX functions. The most widespread in BI is CALCULATE, and one family of filter-changing functions includes ALLSELECTED.
CALCULATE is your tool to alter existing filter context. ALLSELECTED is one of the most often used options for making such changes.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
What Exactly Is ALLSELECTED and When Is It Used?
DAX's ALLSELECTED is referred to as a table function, meaning it can return an entire table and clear out parts of the current filter context. In contrast to other filter functions in Power BI, it doesn't just clean up whatever it pleases.
It clears all filters on tables and columns from the active visualization while keeping all external filters and slicers.
This is a pivotal point as this is what most users are really after when talking about "Total percent." They do not want a percentage of a grand master sum. They want the percentage out of the total for the filtered view.
How Does ALLSELECTED Work vs. Other DAX Functions?
Understanding which filters have to be removed and which should be kept can seem like a complex task. To simplify, we must compare it with its sibling ALL() to understand its importance:
ALL(): Removes all filters/selectors/filter items from a table or a column, whether from a visual, an Excel report, etc. UseALL()when you need to compare or compute the result with absolute grand totals.ALLSELECTED(): Cleans up filters in your visualization or table, such as a row or column headers, while respecting anything filtered by an external slicer. Use this function to work with a subsection of your overall dataset.
For example, if a slicer for “Region” is applied and filtered for ‘North America,’ the ALL function will ignore it, while ALLSELECTED will take notice and just provide the totals for North America.
An Example: Calculate the Percentage of Total in Visual View
A common use for functions like ALLSELECTED is to analyze the contribution each element makes to the whole displayed on the screen, not the entire database available.
Assume we have the following table and sample product sales data. Our goal is to see how much one category is contributing to the filtered regions by our filters.
Step 1: Get the Standard Measure for Total Sales in the Organization
First, check for a simple SUM for the total sales. This can be achieved using DAX:
Total Sales = SUM(Sales[Revenue])This measure will respect everything filtered from our visualization on the part it is displayed.
Step 2: Generate Sales Totals Using CALCULATE and ALL Function
Now, let's get a measure to find that percentage of the total. Your first thought might be to use the ALL function. This is common, and one must realize soon that the result must be fixed.
Sales Grand Total (ALL) = CALCULATE([Total Sales], ALL(Products))This step will give you the total for the entire database, regardless of other fields that are applied, but you must see that your result will always be the same, prompting a change in the scope for your new measures.
Step 3: Generate Dynamic Total Sales with ALLSELECTED
Here comes our superhero to help. The best way is by creating another dynamic measure for getting totals that will adapt automatically to external filter items.
Sales Visible Total (ALLSELECTED) = CALCULATE([Total Sales], ALLSELECTED(Products[Category]))This measure will ignore the Product Category itself, but will consider the values for 'REGION' which we have selected to be filtered by another filter.
Step 4: Calculate the Dynamic Percentage
This will get everything on track. We can now display a final result that makes much more business sense.
% of Visible Total = DIVIDE([Total Sales], [Sales Visible Total (ALLSELECTED)])When that is added to a table next to the ALL methodology, the difference is shown in the visual. If we filter to "North America and Europe," the values in the ALL column might be very small in percentage, whereas the Visible totals must sum to 100%, adjusting everything else, making any insight you might create for the customer much more usable for the actual end user of the business report.
DAX functions in Power BI such as ALL and ALLSELECTED are so important because Power BI provides a wide variety of filter functions such as ALLEXCEPT.
A good way to choose the correct one:
- You want to select the percentage of all the grand total from your whole data: It is
ALL(). - I want the percentage of whatever I'm seeing currently selected on the filtered values (or just selected on the filters list on the left side of Power BI): It will be
ALLSELECTED(). - In case you are looking to keep some filters but clean all the rest or reset filters in Power BI, your choice should be
ALLEXCEPT(). This allows keeping filters which are explicitly selected by user like 'Year', while resetting anything else for filtering, ensuring users always get the same field view as the total for the selected filter inALLEXCEPTparameters.
Second Example: Get Dynamic Rankings for Selected Filters
An alternative powerful use of ALLSELECTED is using it with rankings by only considering current filtered data and getting the rank on that. Say you have a region slicer on your report and you want to rank your sellers just inside the regions which the user is viewing.
When you write rank measures, it often looks like what we have below with this RANKX:
Overall Rank = RANKX(ALL('Sales Reps'[Name]), [Total Sales], , DESC)With ALL(), we get the sales person to a global ranking using total sales for every sales person which will not take into account any filter selection at all. When trying to check from selected options in region slicer, that number could be irrelevant, so we have to improve our RANKX formula.
Free PDF · the crash course
AI Agents for Marketing Crash Course
Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.
Generating a Dynamic Rank Measure
Using ALLSELECTED function, we can generate a sales rank just for people who we view from our current slicers/filters.
Visible Rank = RANKX(ALLSELECTED('Sales Reps'[Name]), [Total Sales], , DESC)The logic is that we want DAX to iterate over the RANKX table which is a filtered result from our ALLSELECTED results, giving back just the currently selected sales person for the views we have. In that way, we will only compare sales in that selected group to get proper values on our ranking without distorting all our data.
Tips & Tricks to Avoid Mistakes
While using such functions for filtering data, always pay attention to some things as their behavior depends on many factors in the Power BI engine:
- Using your functions with no active slicers/filters: In case there are no externally selected filters,
ALLSELECTEDbehaves almost likeALLsince there are no selectors to respect, and this might get confusing. - Using the wrong column for filter function parameters: When you use functions such as
ALLSELECTED(), it is essential to ensure that the columns being filtered are those with the same names and content as your visualizations or tables. If the visual is using Product.Category, it is important to use that particular name in its expression and not one from a related table as it could lead to inconsistency. - Naming measures correctly: When you generate too many measures, they must be correctly labeled to differentiate them easily. This is essential for making our formulas much easier to read and debug in Power BI. Use something like
[Sales% from ALL]and[Sales % of visible totals]. This will avoid lots of confusion.
Final Conclusion with Thoughts and Considerations
ALLSELECTED might not be easy to understand how it works at first, but after spending time creating correct measures, you will understand that DAX in Power BI will save a lot of time and allow for much more interaction between users and Power BI reports. This makes it a good option for improving user interaction and UX with your solution by applying filters for better and faster decision-making for any company, no matter the size.
That level of work and learning how some tools work so complexly, as we have seen using DAX, and the time to master all the formulas is exactly why we started our platform: Graphed. It offers every employee insights without the need to write queries in any language and to start working on analysis with plain English. We just focus on getting insights and nothing else, and our tools do the rest for us. With Graphed, you only need to connect to your sources and start asking questions. Forget about everything which means wrangling data again.
Related Articles
Facebook Ads for Bail Bonds: The Complete 2026 Strategy Guide
Learn the proven strategies bail bond agencies use to generate leads in 2026 despite Facebook and Google ad bans. Includes local SEO, review strategy, and Bing Ads tactics.
Facebook Ads for Security Companies: The Complete 2026 Strategy Guide
Learn how to run effective Facebook ads for security companies in 2026. Discover proven targeting strategies, ad copy templates, and campaign optimization tips for security businesses.
Facebook Ads for Coaches: The Complete 2026 Strategy Guide
Learn how coaches use Facebook ads to generate premium clients in 2026. Discover the proven funnel strategy, creative formulas, and budget guidelines that work.