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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors