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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

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
v-tangjie-msft
Community Support
Community Support

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
v-tangjie-msft
Community Support
Community Support

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]) ) 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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