cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

distinct count of multiple columns

My data contains FName, LName, MName, Gender, Card ID, Health ID, Active Flag and there may be Null in any column for each row i am trying to calculate distinct count  (FName+Card ID+Health ID) and distinct count  (FName+Card ID+Health ID+Where Gender=M)

FNAMELNAMEMNAMEGenderCard IDHealth IDActiveFlag
ABCDXM123456712345Y
BCEFYM981056167891N
ABCDXM123456712345Y
IHPQZM456789034564N
IMPYCF 56789N
   F145647867890N
MEEEBM 78901N
ABCDXM123456712345Y
BCEFYM981056167891N




Please help me with this.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Solution Sage
Solution Sage

Re: distinct count of multiple columns

Create two measures and try the following Dax

 

Measure1 = COUNTROWS(GROUPBY(User,User[FNAME],User[Card ID],User[Health ID],User[Gender]))
Measure2 = COUNTROWS(FILTER(GROUPBY(User,User[FNAME],User[Card ID],User[Health ID],User[Gender]),User[Gender]="M"))

2018-06-06_9-32-30.png

 

 

 

View solution in original post

4 REPLIES 4
Highlighted
Resident Rockstar
Resident Rockstar

Re: distinct count of multiple columns

Hi

 

1. Create a new column :   New_Col = 'Table1'[FNAME]&'Table1'[Card ID]&'Table1'[Health ID]

 

2. Then you can create measure to do the count as needed:

 

Dist_cnt = CALCULATE(DISTINCTCOUNT('Table1'[New_Col]))

 

Dist_Male_Cnt=CALCULATE(DISTINCTCOUNT('Table1'[New_Col]),'Table1'[Gender]="M")

 

Hope this helps.

 

Thanks
Raj

 

Highlighted
Solution Sage
Solution Sage

Re: distinct count of multiple columns

Create two measures and try the following Dax

 

Measure1 = COUNTROWS(GROUPBY(User,User[FNAME],User[Card ID],User[Health ID],User[Gender]))
Measure2 = COUNTROWS(FILTER(GROUPBY(User,User[FNAME],User[Card ID],User[Health ID],User[Gender]),User[Gender]="M"))

2018-06-06_9-32-30.png

 

 

 

View solution in original post

Highlighted
Frequent Visitor

Re: distinct count of multiple columns

Thanks Jessica the Measures are working.

Highlighted
Resolver II
Resolver II

Re: distinct count of multiple columns

Hi,

I am wondering which is the best solution in terms of performance?

Concatenate Calculated Column ?
OR
GroupBy Measure ? 

Thank you in advance,

Rob

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors