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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
saver7890
Frequent Visitor

Distinct Row Count

Hi,

 

Newbie here. I have encountered difficulties in figuring out how to calculate distinct rows from two columns. 

I have two tables(see figure):

  1. 'Ward_Bed' and its respective admission and discharge date;
  2. The number of 'Admitted' (N= 385) and 'Discharge' (N = 355) within the distinct list of 'DATE' (N = 394).

saver7890_1-1678435947815.png

saver7890_2-1678436323368.png

I use the "manage relationships" function by "DOA" of the two tables and my final matrix as follows.

saver7890_3-1678436954094.png

My intention is to compute the distinct countrow of the distinct count of DOA and DOD. 

Although the distinct count of totals are correct, the column value within the matrix are identical between DATE and DOA. 

I expect the Pediatric Ward to have 50 count under DATE instead of 34 after remove duplication of the appending DOA and DOD by excel. 

 

Thank you in advance for your help.

 

 

 

3 REPLIES 3
saver7890
Frequent Visitor

Update with sample data.

https://docs.google.com/spreadsheets/d/1asJJq71M1E2DXQw8ctwMzGoA4np8deOp/edit?usp=sharing&ouid=10435...

 

The closest I get to work by using the following DAX:  

CALCULATE(DISTINCTCOUNT('inpatient service day'[DOA]),'inpatient service day'[DOA]<>BLANK()) + CALCULATE(DISTINCTCOUNT('inpatient service day'[DOD]),'inpatient service day'[DOD]<>BLANK())
 
Only two manage to get the right count. 
saver7890_2-1678591622967.png

Only two manage to get the right count. 

 

It might has to do with two columns calculated as distinct count, ended up with 2 count. I want the 18/2/2020 counted as 1. How can this be achieved?   
saver7890_1-1678591375776.png

 

Thank you all in advance with any guidance would be appreciated.
amitchandak
Super User
Super User

@saver7890 , Based on what I got, check if the approach having a date table and active inactive relation and using userelationship can help

 

Power BI: HR Analytics - Employees as on Date : https://youtu.be/e6Y-l_JtCq4
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

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

Thank you for your attention. 

Yes, there is a date table and active relation. 

I tried your DAX syntax but the value is still off.

For example, the VIP ward should have 4 distinct counts as the "DOA" and "DOD" have different dates.

saver7890_0-1678447278127.png

saver7890_1-1678447442397.png

Thank you.

 

 

 

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors