cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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_id level_3 1280590690 Actions 1280590690 Contact 1280590690 Actions 1280590690 Actions 1280590690 Actions 1280590690 Contact 1280590690 Contact
1 ACCEPTED SOLUTION
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.

(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.

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.

2 REPLIES 2
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.

(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.

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.

Super User

@Moe_M , not very clear but try like

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

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

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

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors