<!-- https://learnsql.cpetoday.com/functions/dax/allselected -->
# ALLSELECTED

Language: DAX
Category: Filter and context
Syntax: ALLSELECTED(<table> | <column> [, <column> ...])
Summary: Returns the rows or values that remain after slicers and page filters, ignoring the visual's own row and column grouping.
Returns: A table. Inside CALCULATE, it removes the filters from the visual's own rows and columns but keeps the outside filters.
Level: Advanced
Related: ALL, ALLEXCEPT, VALUES, CALCULATE, RANKX, TOPN

## What it does
ALLSELECTED returns the items the user has selected, as a total across the visual. Inside a visual, each row or column of a matrix normally filters the measure down to that cell. ALLSELECTED lifts that row or column filter but keeps the slicers and page filters. The usual business use is percent of the selected total: the share of the visible categories or customers, which is what most readers expect when they slice a report.

## Syntax and arguments
- **table or column**: the set of values whose filter from the visual's own axes should be ignored. Name the column that drives the rows of the visual.
- Several columns can be listed. Each one keeps its outside filter.

## Example
Each product category's share of the categories the user has selected in the slicer.

```dax
Share of Selected Sales =
DIVIDE (
    [Total Sales],
    CALCULATE ( [Total Sales], ALLSELECTED ( Product[ProductCategory] ) )
)
```

In a table with one row per category, the denominator equals the total of the categories on screen. If a slicer selects only two categories, those two are the base, and their shares add up to 100 percent.

## Example: a second use
The average sales per store, across the stores the user has selected.

```dax
Average Sales per Selected Store =
AVERAGEX (
    ALLSELECTED ( Stores[StoreName] ),
    [Total Sales]
)
```

The iterator visits each selected store, uses its total, and averages the results. A card with this measure shows the average for the selection, not for all stores.

## Things to watch
- ALLSELECTED still applies slicers. `ALL` does not. Choose the one that matches what the reader expects.
- Name the column the visual is grouped by. Naming a different column gives a base that does not match the rows on screen.
- Totals in a percent measure based on ALLSELECTED usually show 100 percent, which is correct for a share of the selection.
- The denominator changes when someone changes a slicer. Label the measure so readers know the base is the selection.
- Works well for lists of hundreds of items. Check speed on very large lists.

## In business terms
Percent of visible total for management reports, mix across the selected categories, and averages per selected branch or entity. Use it when a controller wants shares to add to 100 percent for whatever the page is showing.
