Forum Discussion

thepuzzlemaster's avatar
thepuzzlemaster
Frequent Visitor
3 years ago
Solved

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  [email protected]
124becky riley[email protected]


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
123[email protected]m  12
  24
124[email protected]36

 

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
123[email protected]m  112
  201
 [email protected]112
  201
124[email protected]300
 [email protected]300

 

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!

  • lbendlin's avatar
    lbendlin
    3 years ago

    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.

     

     

5 Replies

    • thepuzzlemaster's avatar
      thepuzzlemaster
      Frequent Visitor

      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

      • lbendlin's avatar
        lbendlin
        Super User

        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.