Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MCacc
Helper IV
Helper IV

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
amitchandak
Super User
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
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Barthel
Solution Sage
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.

Barthel_0-1659354445528.png

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] )

View solution in original post

Thank you so much, it works!

View solution in original post

4 REPLIES 4
Barthel
Solution Sage
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.

Barthel_0-1659354445528.png

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] )

Thank you so much, it works!

amitchandak
Super User
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
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks! it works as well!! 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.