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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
StephenK
Resolver I
Resolver I

Distinct Count of Value Where Distinct Count of Another Value >1 And Value = Value

Hey all,

 

I need to write a DAX formula to get a slightly complicated distinct count.

 

Here is a sample table:

PersonIdVisitIdReportId
195999
1951000
1951001
2100545
3123697
3231201

 

I need a distinct count of PersonId where distinct count of ReportId>1 on the same VisitId

 

So for example PersonId 1 has 3 distinct ReportId's on VisitId 95, so only that id should be counted in the formula. PersonId 2 and PersonId 3 do not have multiple ReportId's on the same VisitId so they should not be counted. Hope that makes sense.

 

Any help would be appreciated!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

[Measure] =
CALCULATE(
	DISTINCTCOUNT( T[PersonId] ),
	FILTER(
		// This table grabs all the existing
		// combinations of person-visit visible
		// in the current context.
		SUMMARIZE(
			T,
			T[PersonId],
			T[VisitId]
		),
		// This condition just filters the pairs
		// where the person has at least 2 reports
		// for the currently interated visit.
		CALCULATE(
			DISTINCTCOUNT( T[ReportId] ) > 1
		)
	)
)

 

Best

D

View solution in original post

1 REPLY 1
Anonymous
Not applicable

[Measure] =
CALCULATE(
	DISTINCTCOUNT( T[PersonId] ),
	FILTER(
		// This table grabs all the existing
		// combinations of person-visit visible
		// in the current context.
		SUMMARIZE(
			T,
			T[PersonId],
			T[VisitId]
		),
		// This condition just filters the pairs
		// where the person has at least 2 reports
		// for the currently interated visit.
		CALCULATE(
			DISTINCTCOUNT( T[ReportId] ) > 1
		)
	)
)

 

Best

D

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.