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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
thescrimpton
Frequent Visitor

ISINSCOPE messes up matrix

I have 3 tables. These are the typical Customer, Product, Sales tables. Sales is just simply the mapping of Customer and what Product they bought. Below are the contents of the tables and how they relate.

thescrimpton_0-1664697200444.png

thescrimpton_1-1664697296360.png
Then I created the measure :

IsInScopeFlag =
ISINSCOPE('Product'[ProductName])
 

For some reason, this measure messes up the row count of my matrix.

Matrix before ISINSCOPE.

thescrimpton_2-1664697418760.png
Matrix after adding IsInScopeFlag

thescrimpton_3-1664697617841.png

However I found a workaround to make this work. Instead of referring to the columns 'CustomerName' and 'ProductName' in their respective dimension tables, what I did was to create calculated columns of 'CustomerName' and 'ProductName' in Sales (making it redundant) and usee them in the matrix. For some reason this did the trick. I also created a new measure IsInScope2 to refer to the newly created column.

 

RedundantCustomerName =
RELATED(Customer[CustomerName])

RedundantProductName =
RELATED('Product'[ProductName])
 
IsInScopeFlag2 =
ISINSCOPE(Sales[RedundantProductName])


thescrimpton_4-1664697951721.png

 
My questions are:
1. Why does the first IsInScope measure messes up the matrix? (I am thinking this is about the relationship.)
2. Is my workaround the only way to do this? Or this there a way to make it work using DAX/Power BI trick without creating redundant columns and maintaining the relationship of the tables.


Thanks Power BI Community!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@thescrimpton The answer to your first question is that ISINSCOPE just checks if the column is or is not in scope and returns true or false. Since you aren't aggregating any value, basically the filtering going on with the table relationships doesn't come into play when calculating this measure so you will always get back True or False and since you get a value back for each Product, then that row is displayed in your matrix. It would be the same thing as if you created a measure that returned a constant value.

 

Would need you to post sample data to mock this up. Good chance there is a different trick for this. One thing you might try is making your Product to Sales relationship bi-directional.

 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@thescrimpton The answer to your first question is that ISINSCOPE just checks if the column is or is not in scope and returns true or false. Since you aren't aggregating any value, basically the filtering going on with the table relationships doesn't come into play when calculating this measure so you will always get back True or False and since you get a value back for each Product, then that row is displayed in your matrix. It would be the same thing as if you created a measure that returned a constant value.

 

Would need you to post sample data to mock this up. Good chance there is a different trick for this. One thing you might try is making your Product to Sales relationship bi-directional.

 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I didn't realize this is happening on the background until you add a measure. Thanks for the reply @Greg_Deckler.

Since you aren't aggregating any value, basically the filtering going on with the table relationships doesn't come into play when calculating this measure so you will always get back True or False and since you get a value back for each Product, then that row is displayed in your matrix.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.