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
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
July 2025 community update carousel

Fabric Community Update - July 2025

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

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.