Explanation
ALLSELECTED is one of the most complex functions in DAX. When used improperly it can lead to unexpected results. As a rule of thumb, you should not use it in iterative functions. It is preferable to use it only as a CALCULATE filter remover, not as a table function.
ALLSELECTED comes into play once we want to make a distinction between direct filters plotted on a specific visual (e.g. matrix table in the picture below), and filters coming from other visuals on the canvas (e.q. color Slicer). If used as a CALCULATE filter remover, ALLSELECTED ignores all direct filters but keeps all indirect ones (such as the one coming from the Slicer).
ALL Color = CALCULATE([SalesAmount],ALL(DimProduct[Color])) ALLSELECTED Color = CALCULATE([SalesAmount],ALLSELECTED(DimProduct[Color]))
As we can see in the picture above, if there are no filters coming from other visuals on the canvas, both types of calculation return the same value, which is the [SalesAmount] with the colors column ignored. The difference becomes evident once we introduce cross-filtering across visuals.
This time we can see a clear difference between the 2 measures. [ALL Color] is ignoring both direct and cross-filtered filters on the DimProduct[Color] column, while [ALLSELECTED Color] is removing only the DimProduct[Color] filter which is directly applied to the visual. The one coming from the slicer is preserved, therefore limiting the ALLSELECTED measure to ignore only the visible filters in the visual.
ALLSELECTED is mostly used to perform dynamic share in segment calculations.