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
Moe_M
Regular Visitor

Distinct count based on 2 or more values of another column

Good day all, 
I have a dataset that looks like below. I was trying to get a distinct count of 'sentence_id' column when 'level_3' is both 'actions' and 'contacts'. 

sentence_idlevel_3
1280590690

Actions

1280590690

Contact

1280590690

Actions

1280590690

Actions

1280590690

Actions

1280590690

Contact

1280590690

Contact

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Moe_M ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1695366706087.png

(2) We can create a measures. 

Measure = CONCATENATEX(FILTER(ALLSELECTED('Table'),[sentence_id] in VALUES('Table'[sentence_id])),[level_3],",")
Measure 2 = var a={"Actions","Contact"}
var b=COUNTROWS(FILTER(a,CONTAINSSTRING([Measure],[Value])))
return IF(b=COUNTROWS(a),1,0)
Measure 3 = CALCULATE(DISTINCTCOUNT('Table'[sentence_id]),FILTER('Table',[Measure 2]=1))

(3) Then the result is as follows.

vtangjiemsft_1-1695368037632.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Moe_M ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1695366706087.png

(2) We can create a measures. 

Measure = CONCATENATEX(FILTER(ALLSELECTED('Table'),[sentence_id] in VALUES('Table'[sentence_id])),[level_3],",")
Measure 2 = var a={"Actions","Contact"}
var b=COUNTROWS(FILTER(a,CONTAINSSTRING([Measure],[Value])))
return IF(b=COUNTROWS(a),1,0)
Measure 3 = CALCULATE(DISTINCTCOUNT('Table'[sentence_id]),FILTER('Table',[Measure 2]=1))

(3) Then the result is as follows.

vtangjiemsft_1-1695368037632.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

amitchandak
Super User
Super User

@Moe_M , not very clear but try like

 

countrows(summarize(Table, Table[sentence_id], Table[level_3]) ) 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.