cancel
Showing results for
Did you mean:
Helper III

## How to use ISINSCOPE

Hello,

I'm trying to apply a conditional formatting to my visual matrix.

I have two levels (LEVEL 1, LEVEL 2) which have different measures which I will apply to set my condtional formatting.

I've read I can use ISINSCOPE:

MEASURE FOR COLORING

VAR LEV_1 = ISINSCOPE(TABLE[LEVEL 1])
VAR LEV_2= ISINSCOPE(TABLE[LEVEL 2])
RETURN
SWITCH (
TRUE(),
LEV_1, [MEASURE FOR LEVEL 1],
LEV_2, [MEASURE FOR LEVEL 2])

I expect to have 1 or 0, so my conditional for the backround will be if my MEASURE FOR COLORING value = 1, red.

Unfortunately it doesn't work.

Do you have any idea. Thank you!
3 ACCEPTED SOLUTIONS
Super User

@MCacc , you should in reverse order. So if level one is above in a visual and level 2 is below, then use Level2, level 1

MEASURE FOR COLORING

VAR LEV_1 = ISINSCOPE(TABLE[LEVEL 1])
VAR LEV_2= ISINSCOPE(TABLE[LEVEL 2])
RETURN
SWITCH (
TRUE(),
LEV_2, [MEASURE FOR LEVEL 2],
LEV_1, [MEASURE FOR LEVEL 1] )

IsInScope - Switch Rank at different levels: https://youtu.be/kh0gezKICEM

Learn Power BI - Full Course with Dec-2022, with new DAX functions like Window, Index, Offset !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Formatted Profit and Loss Statement with empty lines
Solution Sage

Hey,

ISINSCOPE in combination with a matrix works from top to bottom. The highest rank is always in scope, and the ranks below it only when expanded.

SWITCH also works from top to bottom on an exclusion basis. Therefore first use the LVL2 condition and then the LVL1 condition:

``````MEASURE FOR COLORING =
VAR LEV_1 =
ISINSCOPE ( TABLE[LEVEL 1] )
VAR LEV_2 =
ISINSCOPE ( TABLE[LEVEL 2] )
RETURN
SWITCH ( TRUE (), LEV_2, [MEASURE FOR LEVEL 2], LEV_1, [MEASURE FOR LEVEL 1] )``````
Helper III

Thank you so much, it works!

4 REPLIES 4
Solution Sage

Hey,

ISINSCOPE in combination with a matrix works from top to bottom. The highest rank is always in scope, and the ranks below it only when expanded.

SWITCH also works from top to bottom on an exclusion basis. Therefore first use the LVL2 condition and then the LVL1 condition:

``````MEASURE FOR COLORING =
VAR LEV_1 =
ISINSCOPE ( TABLE[LEVEL 1] )
VAR LEV_2 =
ISINSCOPE ( TABLE[LEVEL 2] )
RETURN
SWITCH ( TRUE (), LEV_2, [MEASURE FOR LEVEL 2], LEV_1, [MEASURE FOR LEVEL 1] )``````
Helper III

Thank you so much, it works!

Super User

@MCacc , you should in reverse order. So if level one is above in a visual and level 2 is below, then use Level2, level 1

MEASURE FOR COLORING

VAR LEV_1 = ISINSCOPE(TABLE[LEVEL 1])
VAR LEV_2= ISINSCOPE(TABLE[LEVEL 2])
RETURN
SWITCH (
TRUE(),
LEV_2, [MEASURE FOR LEVEL 2],
LEV_1, [MEASURE FOR LEVEL 1] )

IsInScope - Switch Rank at different levels: https://youtu.be/kh0gezKICEM

Learn Power BI - Full Course with Dec-2022, with new DAX functions like Window, Index, Offset !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Formatted Profit and Loss Statement with empty lines
Helper III

Thanks! it works as well!!

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### 2022 Monthly Feature Releases

We had a great 2022 with a ton of feature releases to help you drive a data culture.

Top Solution Authors
Top Kudoed Authors