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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

Creating relationship and summarizing 1 to many table

I have Study Table:

StudyIDIRBProtoTypeType
122234outother
25556innew
333899inold
499567innew
51123outnew
69432outold
728766n/anew

 

Patient Table

StudyidPatIDstatusdateLocation
1sd345461/1/2009in
1sd909925/23/2009us
2sd14743811/15/2010russia
4sd2038841/1/2009japan
3sd2603305/23/2011in
3sd31677611/15/2012us
3sd3732221/1/2017russia
6sd4296681/1/2009japan
6sd4861145/23/2018in
7sd54256011/15/2019us
2sd5990061/1/2009russia
4sd6554525/23/2013japan

 

I want to summarize to create a table below

StudyIDIRBProtoTypeTypePatCount
122234outother2
25556innew2
333899inold3
499567innew2
51123outnew0
69432outold2
728766n/anew1

I want to create a slice on the patient table[statusdate] and want to filter based on the statusdate

 

I have a problem creating relationships between table and the date.

How do i create the PatCount measure

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , if you want to create a new table .

You can merge in power query it will give the option of aggregation when you expand

https://radacad.com/append-vs-merge-in-power-bi-and-power-query

 

In dax refer

https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/

 

If the are one to many relation you can create measure like this

measure = count(Patient[PatID])

measure = count(Patient[PatID])+0 //to display all record

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
ryan_mayu
Super User
Super User

@Anonymous 

you can create a new column

Column = CALCULATE(COUNTROWS(patient),FILTER(patient,patient[Studyid]=study[studyID]))+0

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

I also want to use the slicer in the visualization and abe able to filter by statusdate in patient table.

If we don't have a relationship how can we filter it?

@roopesh

if you do not have the relationship between two tables, use the TREATAS function

Measure = CALCULATE(COUNT(patient[PatID]),TREATAS(VALUES(study[StudyID]),patient[Studyid]))+0

1.PNG2.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.