Know which level you’re on: row labels with ISINSCOPE

Tell product rows, category subtotals and the grand total apart in a two-level matrix with ISINSCOPE and SWITCH(TRUE()).

You will learn to

  • Test whether a column is grouping the current row with ISINSCOPE
  • Check the deepest level first in SWITCH(TRUE())
  • Explain how ISINSCOPE differs from HASONEVALUE

How it works

In a two-level matrix (Category, then Product) there are three kinds of rows: **product rows**, **category subtotals** and the **grand total**. Many measures need to behave differently on each.

`ISINSCOPE(column)` is TRUE when that column is one of the groupings of the current row. On a product row both Category and Product are in scope; on a category subtotal only Category is; on the grand total neither is.

So test the **deepest** level first. If you test Category first, product rows match it too, because Category is in scope there as well.

ISINSCOPE only looks at the visual’s own grouping. A filter that happens to leave one product visible, from a slicer or the filter pane, is not a row of the matrix: ISINSCOPE says FALSE there, while `HASONEVALUE` would say TRUE.

Practice it hands-on with a real data model and a live report that updates as you type.

Region Level = SWITCH(TRUE(), ISINSCOPE(Customer[Customer]), "customer row", ISINSCOPE(Customer[Region]), "region subtotal", "all regions")