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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
ravi_609
Helper I
Helper I

How to calculate conditional customer distinct count?

Hello Friends,
I have attached data table below:

ravi_609_0-1704310532031.png


I need distinct count of CustomerID for "V1-V2" Common Vertical.
Note: If any customer have only "V1" Vertical and "V1-V2-V3"  then it will not count as V1-V2 Common Vertical.

Expected Output:
From dataset image only 2 customer in V1-V2 common group. so measure will give me 2 count.

Please help me out how to write dax for this type of condition.
Thank you once again in advance...!!!

1 ACCEPTED SOLUTION

@ravi_609 

I tested withthe sample youprovided and it worked for me.can you explain how are youtrying to apply this measure?

My table:

Fowmy_0-1704350965696.png


The meaure and the result:

Fowmy_1-1704351005944.png

Porvide more details and screenshots of the error. You may also share dummy data that represent your actual data structure.


 




 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Share data in a format that can be pasted in an MS Excel file.  Sharing an image is useless!!!!


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Fowmy
Super User
Super User

@ravi_609 

Try this measure:

COUNTROWS(
	FILTER(
		ADDCOLUMNS(
				DISTINCT(Table06[CustomerID] ),			
				"V" ,
				VAR __A = COUNTROWS( CALCULATETABLE( VALUES( Table06[Vertical] ) , TREATAS( {"V1" ,"V2"} , Table06[Vertical] )) )
				VAR __B = COUNTROWS(CALCULATETABLE( VALUES( Table06[Vertical] ) ) )
				RETURN
				INT(AND(__A=2 ,__B=2))
		),
		[V] = 1
	)
)

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy Thanks for the response but This measure is not working...!!!


I got solution with SQL Server Query:
SELECT CustomerID,COUNT(Verical)
FROM Vertical
GROUP BY CustomerID
HAVING CustomerID not in (Select CustomerID From Vertical where Verical not in ('V1','V2')) and COUNT(Verical) = 2

But I am stuck here that how to use this same logic into measure.

@ravi_609 

I tested withthe sample youprovided and it worked for me.can you explain how are youtrying to apply this measure?

My table:

Fowmy_0-1704350965696.png


The meaure and the result:

Fowmy_1-1704351005944.png

Porvide more details and screenshots of the error. You may also share dummy data that represent your actual data structure.


 




 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Corey_M
Resolver II
Resolver II

 

UniqueIDCount = 
COUNTROWS(
    FILTER(
        SUMMARIZE(
            YourTable,
            YourTable[ID],
            "Verticals", CONCATENATEX(VALUES(YourTable[vertical]), YourTable[vertical], ",")
        ),
        (CONTAINSSTRING([Verticals], "V1") && CONTAINSSTRING([Verticals], "V2")) 
        && NOT CONTAINSSTRING([Verticals], "V3")
    )
)

 

not the most eloquent solution, but this should work

@Corey_M   Thanks for the response but This measure is not working...!!!

I got solution with SQL Server Query:

SELECT CustomerID,COUNT(Verical)
FROM Vertical
GROUP BY CustomerID
HAVING CustomerID not in (Select CustomerID From Vertical where Verical not in ('V1','V2')) and COUNT(Verical) = 2

But I am stuck here that how to use this same logic into measure.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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