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
cjacobson
Frequent Visitor

Table relationship (one-to-many) not working in visual

I have two tables:

Patients has unique idPatient

UPDRS has scores (multiple per patient) and is linked to Patients via idPatient

diagram.PNG

 

Here's my one-to-many relationship:

 

Relationship 2.PNG

By everything I've read here and elsewhere this seems to be the right way to do it.

 

However, the simplest visual I could think of just shows the total number of patients for every option. I did a New Measure to count the number of patients.

Number Patients = DISTINCTCOUNT('Patients'[idPatient])

Then I created a table visual with intQ18 (possible answers of 0 through 4) and that Measure. Since it didn't work I also tried letting PowerBI do a distinct count.

visualization tables.PNG

As an example: idPatient 1625 scored a 1, 2, and 4 at different times and should be counted in those buckets and not the other ones.

 

Things I have tried:

  • Making sure the relationship is active
  • EDIT: Switching the direction of the relationship
  • Switching intQ18 from Sum to Don't Summarize
  • In modeling view, switching idPatient in both tables from Whole Number to Text
  • Checking that the number of rows in the Patients table matches the number of rows in the actual patient table in the database (no duplicates)

Your help is much appreciated.

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@cjacobson change your DAX like this

 

Number Patients = DISTINCTCOUNT(udpr[idPatient])


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@cjacobson change your DAX like this

 

Number Patients = DISTINCTCOUNT(udpr[idPatient])


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k Seems to have worked!

 

So the short version is "do your counting in the table that has 'many' IDs, not in the table that has 'one' ID". Is that correct? Is it only true for if the thing you are "grouping by" like my intQ18 is in the 'many' table?

 

Thank you!

 

@cjacobson it depends what you are trying to do, if you have using column from many side then your calculation should be on many side column, in this case you are counting by column from many side which cannot filter patient table, although that can be achieved by cross filter direction set to both.

 

So there are many option, it all depends what you are trying to achieve and how you set up you data model.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

OK, wonderful. I will try to keep that in mind. 

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.