Short answer: ISINSCOPE ( column ) returns TRUE when the visual is grouping by that column at the current cell, that is, on the rows of that level and below, and FALSE on subtotals and totals above it. Use it to blank totals that make no sense (a rank, an average price), to show percent of parent at each level of a matrix, and to switch the calculation by level. Unlike HASONEVALUE, it is not fooled by a slicer that selects one value.
A matrix with Category, Product and a "rank" measure shows a rank on the total row, which means nothing. ISINSCOPE says "only show this at product level".
How does it differ from HASONEVALUE?
| Row | ISINSCOPE ( Product ) | ISINSCOPE ( Category ) | HASONEVALUE ( Category ) |
|---|---|---|---|
| Bikes, Mountain-200 | TRUE | TRUE | TRUE |
| Bikes (subtotal) | FALSE | TRUE | TRUE |
| Total | FALSE | FALSE | TRUE |
On the grand total, HASONEVALUE ( Category ) is TRUE because the slicer leaves one category; ISINSCOPE ( Category ) is FALSE because the total does not group by category. That is why ISINSCOPE is the right test for "am I on a total row?".
Which patterns use it?
-- 1 blank the total of a rank
Product Rank =
IF ( ISINSCOPE ( 'Product'[Product] ), RANKX ( ALLSELECTED ( 'Product'[Product] ), [Revenue] ) )
-- 2 percent of parent at each level
% of Parent =
SWITCH (
TRUE (),
ISINSCOPE ( 'Product'[Product] ),
DIVIDE ( [Revenue], CALCULATE ( [Revenue], ALLSELECTED ( 'Product'[Product] ) ) ),
ISINSCOPE ( 'Product'[Category] ),
DIVIDE ( [Revenue], CALCULATE ( [Revenue], ALLSELECTED ( 'Product'[Category] ) ) ),
1
)
-- 3 sum of per-product values on totals, a formula on rows
Bonus =
IF (
ISINSCOPE ( 'Product'[Product] ),
[Revenue] * 0.02,
SUMX ( VALUES ( 'Product'[Product] ), [Revenue] * 0.02 )
)Test the lowest level first in SWITCH ( TRUE () ): at product level both Product and Category are in scope.
| Category, Product | Revenue | % of Parent |
|---|---|---|
| Bikes | 2,100 | 72% |
| Mountain-200 | 900 | 43% |
| Road-150 | 1,200 | 57% |
| Accessories | 820 | 28% |
| Helmet | 500 | 61% |
| Bottle | 320 | 39% |
| Total | 2,920 | 100% |
What about visual calculations?
In visual calculations, ISATLEVEL ( [Field] ) reports whether a field is present at the current level, and COLLAPSE gives the parent's value directly: DIVIDE ( [Revenue], COLLAPSE ( [Revenue], ROWS ) ) is percent of parent without any ISINSCOPE.
What goes wrong?
- Testing the higher level first. At product level Category is also in scope; test Product first.
- HASONEVALUE for totals. Fooled by slicers; use
ISINSCOPE. - Columns not on the visual.
ISINSCOPEis FALSE for a column that is not grouped, even if filtered. - DirectQuery. Not supported in calculated columns or RLS rules in DirectQuery mode.
Where can you check this?
- Microsoft Learn: ISINSCOPE function (DAX)
- Microsoft Learn: HASONEVALUE function (DAX)
- Microsoft Learn: ISATLEVEL function (DAX)
Where do you start?
Wrap every rank and per-unit measure in IF ( ISINSCOPE ( ... ) ) so totals stop showing meaningless numbers. RANKX uses it for the total row.