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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
thepuzzlemaster
Frequent Visitor

Matrix Rows - Related table showing all values, rather than just the related one

I have 2 related tables (1: many from Users[userId] -> Homes[ownerId]):
Users:

usersId  name  email  
123john smith  john@smith.com
124becky rileybecky@riley.com


Homes:

ownerId homeId  capacity
12312
12324
12436

 

I also have a 3rd related table (1:many from Homes[homeId] -> Availability[homeId])

homeId  datedate: month
112/12/202212/01/2022
101/10/2023  01/01/2023
101/12/202301/12/2023
201/10/202310/01/2023

 

I have created a matrix, and I want to display the email address associated with a specific owner, but instead it is showing me every owner's email address under each ownerId when I also include the availability data.

I added the following under rows:
Homes[ownerId],
Users[email],
Homes[homeId],

And the following under Values:
Homes[capacity]

I see the following as expected:

ownerId  emailhomeId  capacity
123john@smith.com  12
  24
124becky@riley.com36

 

But if I put Availability[date: month] on columns and a measure which aggregates the availability data on values I get:

ownerId  emailhomeId  December 2022  January 2023
123john@smith.com  112
  201
 becky@riley.com112
  201
124john@smith.com300
 becky@riley.com300

 

If I remove the Users[email] from rows I get the expected result:

ownerId  homeId  December 2022  January 2023
123112
 201
124300

 

 

I imagine there is just some fundamential misunderstanding I have about something here. But I'm confused as to why the inclusion of that aggregated measure would cause the data displayed in the rows to get all wonky.

Thanks!

1 ACCEPTED SOLUTION

Explicit measures require a filter context.  You are trying to report on things that aren't there (gaps in your data).  That requires cross joins and / or disconnected tables. You can also use COALESCE to handle some situations.

 

unavailable/month = COALESCE(DISTINCTCOUNT(Availability[date]), 0)

 

see attached.

 

 

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

It is important to carefully choose which column to take from which table. Generally you want to use the higher level dimension colums first.

 

lbendlin_0-1674402474713.png

lbendlin_1-1674402517661.png

 

see attached

 

Thank you so much for the reply. Apologies for not having fully recreated my issue in a similfied pbix that I could share. I forgot an important detail that I didn't realize was necessary here. 

In my actual visual, I am using a measure as my value, not just an aggregation. I've updated your sample .pbix file with a similar measure to my production report, so that it is reproing my issue. I also added some additional users to the users table, since there are some users who may not have a home, to make it match my real data more closely.

It looks like maybe I can't upload a file yet (fairly new to this forum). I am trying to share via google drive.
Hopefully this works. https://drive.google.com/file/d/1B7tX8-r9I9fhfssf4Cccf464jpeoxkjZ/view?usp=sharing

Explicit measures require a filter context.  You are trying to report on things that aren't there (gaps in your data).  That requires cross joins and / or disconnected tables. You can also use COALESCE to handle some situations.

 

unavailable/month = COALESCE(DISTINCTCOUNT(Availability[date]), 0)

 

see attached.

 

 

Thanks again for the reply and the additional context of what is going on here.

What I ended up doing, which gives me the result I want, is to create an additional column (ownerEmail) on my "Homes" table, which uses a merged query to pull in the email address of the owner from the users table. 

The part that is still confusing to me, is given the relationship I set up between Homes[ownerId] and Users[userId], why isn't the visual recognizing the related email field from the user table when the prior row is ownerId and displaying just the related email? Is this specific to the way a matrix works in particular? Is there a term I could search for in order to read up about this for a more in-depth explanation of why the extra column on the Homes table is necessary to get this to work the way I want it to?

search for "auto exist"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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