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
MickyG
Frequent Visitor

DISTINCTCOUNT() of name without a record that CONTAINS()

I want to get the distinct count of the StudentName that DOES NOT contain a record with the keyword "Withdrawn". So the DAX formula result for the data below should have a  single count for each student's name except for Richard Gear because he has the keyword "Withdrawn" in one of his records. Also, there is a calendar table. If the formula can include filters by date so I can use a slider. The records should be within the MIN() and MAX() of the Calendar Table.

DATA:

MickyG_0-1675264276999.png

 

RESULT:

MickyG_1-1675264621668.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @MickyG ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _min=MINX(ALLSELECTED('Date'),[Date])
var _max=MAXX(ALLSELECTED('Date'),[Date])
return
IF(
CONTAINSSTRING(MAX('Table'[Result]),"Withdrawn")=FALSE()&&
MAX('Table'[Exam Date])>=_min&&MAX('Table'[Exam Date])<=_max,1,0)
Measure =
CALCULATE(DISTINCTCOUNT('Table'[StudentName]),
    FILTER(ALLSELECTED('Table'),
    'Table'[StudentName]=MAX('Table'[StudentName])))

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1675390874595.png

3. Result:

vyangliumsft_1-1675390874600.png

 

Best Regards,

Liu Yang

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
Ashish_Mathur
Super User
Super User

Hi,

Create a calculated column formula

Test = search("Withdrawn",Data[Results],1,0)

To your visual, drag Name and this measure

Measure = calculate(countrows(Data),Data[Test]=0)

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi  @MickyG ,

 

Here are the steps you can follow:

1. Create measure.

Flag =
var _min=MINX(ALLSELECTED('Date'),[Date])
var _max=MAXX(ALLSELECTED('Date'),[Date])
return
IF(
CONTAINSSTRING(MAX('Table'[Result]),"Withdrawn")=FALSE()&&
MAX('Table'[Exam Date])>=_min&&MAX('Table'[Exam Date])<=_max,1,0)
Measure =
CALCULATE(DISTINCTCOUNT('Table'[StudentName]),
    FILTER(ALLSELECTED('Table'),
    'Table'[StudentName]=MAX('Table'[StudentName])))

2. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_0-1675390874595.png

3. Result:

vyangliumsft_1-1675390874600.png

 

Best Regards,

Liu Yang

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

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