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
ssbagley
Helper III
Helper III

Distinct Count (Direct Query) - Why is this so hard!?

Hi - me again.  Source data is employee expense submissions in a SQL table via Direct Query.  I want to count the number of expense reports by employee for a given date range (slicer).  I've tried:

= Countrows(Summarize(Expenses, Expenses[ReportNumber]) )

= DISTINCTCOUNT (Expenses[ReportNumber] )

= COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER(Expenses,Expenses[ReportNumber]<>0),"Reports",Expenses[ReportNumber])))

 

I know this has to be possible -- what am I doing wrong??

6 REPLIES 6
PVO3
Impactful Individual
Impactful Individual

Im sorry. Instead of primairy key i meant your name column. But im afraid this operation over this column has performance issues

I don't want to countrows of the name column though because one name may have 500 unique expense reports.  I want to identify the number of expense reports per person (not number of expense submissions). 

PVO3
Impactful Individual
Impactful Individual

So then do COUNTROWS(ALL(Expenses[ReportNumber]))

That doesn't work, but I figured it out anyway.  Thanks!

PVO3
Impactful Individual
Impactful Individual

COUNTROWS(ALL('Table'[Primairy key])) is working fine for me

This displayed the same value for every employee which is not correct, but it did return a result which is an improvement from my previous attempts!

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
Top Kudoed Authors