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 August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DistinctCount Per specific conditions

Hi Everyone,

 

I have an issue with the correct total of a measure:

 

I"m trying to distinct count the # of Labs (customers) that generate more than $650 in the last half a year.

As you see below, I'm filtered on Date Hierarchy for the last 6 months but the Count if Labs above $650 (1) or the Count if Labs above $650(2) do not sum the correct total per this group of customers (redacted the name). Two attempts which were both unsuccessful

 

Count if Labs above $650 (1):=

if(calculate(Sum(SALES[Rev After XX]),SALES[Division2]="Labs")>650,calculate(DISTINCTCOUNT(SALES[SCC]),keepfilters('Calendar'[Date])),blank())

 

Count if Labs above $650 (2):=

if((calculate(Sum(SALES[Rev After XX]),SALES[Division2]="Labs")/calculate(DISTINCTCOUNT(SALES[SCC]),SALES[Division2]="Labs"))>650,calculate(DISTINCTCOUNT(SALES[SCC]),keepfilters('Calendar'[Date])),blank())

 

You can see in the Revenue Compliant measure I am able to get only the totals for Labs (customers) that are compliant with the 650 rule (vs Revenue All which takes all instances).

 

I'm for some reason not able to get either of distinct count measures to sum to 9...

 

Would very much appreciate your support!

Thanks

Eyal

 

 

 

Example.PNG

1 ACCEPTED SOLUTION
littlemojopuppy
Community Champion
Community Champion

Hi @Anonymous 

This will give you the count of labs with at least 650 in revenue.

VAR	LabSummary =
	ADDCOLUMNS(
		Labs,
		"SixMonthsRevenue",
		CALCULATE(
			[Revenue]
			DATESINPERIOD(
				DateTable[Date],
				MAX(DateTable[Date]),
				-6,
				MONTH
			)
		)
	)
RETURN

COUNTROWS(
	FILTER(
		LabSummary,
		SixMonthsRevenue >= 650
	)
)

Fair warning: I typed this in Notepad so might not be syntactically correct.  Hope this helps.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@littlemojopuppy  i will check it out and and add as a solution as well shortly. Thanks!

littlemojopuppy
Community Champion
Community Champion

Hi @Anonymous 

This will give you the count of labs with at least 650 in revenue.

VAR	LabSummary =
	ADDCOLUMNS(
		Labs,
		"SixMonthsRevenue",
		CALCULATE(
			[Revenue]
			DATESINPERIOD(
				DateTable[Date],
				MAX(DateTable[Date]),
				-6,
				MONTH
			)
		)
	)
RETURN

COUNTROWS(
	FILTER(
		LabSummary,
		SixMonthsRevenue >= 650
	)
)

Fair warning: I typed this in Notepad so might not be syntactically correct.  Hope this helps.

tamerj1
Super User
Super User

Hi @Anonymous 

Try

New Measure =
SUMX (

SUMMARIZE ( Sales, Sales[BUYING GROUP], Sales[SCC] ),

[Old Measure]
)

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.