cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Usates Member
Member

Measure with "does not contain" and/or "is null"

I am creating a measure within Power BI Desktop.  I want it to distinct count all Work Orders that:

1. Has no "Completed Date"

2. The CUSTVEND[ACCTNO] is blank

3. The [On Hold] measure equals 1

4. The WO_HDR[Partnumber] does not contain the work "kit"

 

 

Below is my attempt and it does not work.  Could someone please help.  Thank you!

 

WO on Hold Count = CALCULATE(DISTINCTCOUNT(WO_HDR[Work Order#]),WO_HDR_STATUS[COMPLETED_DATE]= blank(),CUSTVEND[ACCTNO]= blank(),[On Hold]=1,WO_HDR[PARTNUMBER]<>'%kit%')

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-yuezhe-msft
Moderator

Re: Measure with "does not contain" and/or "is null"

Hi @Usates,

Please use the following formula instead, replace tablename with your own table.

WO on Hold Count = CALCULATE(DISTINCTCOUNT(WO_HDR[Work Order#]),WO_HDR_STATUS[COMPLETED_DATE]= blank(),CUSTVEND[ACCTNO]= blank(),FILTER(tablename,tablename[On Hold]=1), FILTER(WO_HDR, WO_HDR[PARTNUMBER]<>"%kit%"))



Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
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

7 REPLIES 7
scottsen Senior Member
Senior Member

Re: Measure with "does not contain" and/or "is null"

'%kit%' is not supported.  You need to use SEARCH or FIND dax funtions, or some flavor of LEFT/RIGHT parsing, etc.

 

scott@tinylizard.com

 

Usates Member
Member

Re: Measure with "does not contain" and/or "is null"

This is not working either.  I removed the "kit" portion of the measure and it is still coming up with an error.  I believe the: = blank() is not correct also.

 

WO on Hold Count = CALCULATE(DISTINCTCOUNT(WO_HDR[Work Order#]),WO_HDR_STATUS[COMPLETED_DATE]= blank(),CUSTVEND[ACCTNO]= blank(),[On Hold]=1,WO_HDR[PARTNUMBER]<>search("kit",WO_HDR[PARTNUMBER],1))

KGrice Established Member
Established Member

Re: Measure with "does not contain" and/or "is null"

I'm sure there's a way to do this solely in your measure without adding a calculated column, but adding a column is much easier at my level. I'll keep playing with the DAX solution, or maybe someone else will jump in, but for now...

 

I'd start by adding a calculated column to determine if "kit" is in your PARTNUMBER.

 

hasKit.PNG

 

That easy True/False column can then be used in your measure. In the screenshot below, I've got a plain COUNTROWS formula, and also a measure that counts rows not containing "kit" in the Part Number:

 

CountKit.PNG

Moderator v-yuezhe-msft
Moderator

Re: Measure with "does not contain" and/or "is null"

Hi @Usates,

Please change your formula to the following formula and check if it returns expected result. If not, please post the detailed error message and sample data of your scenario.
 

WO on Hold Count = CALCULATE(DISTINCTCOUNT(WO_HDR[Work Order#]),WO_HDR_STATUS[COMPLETED_DATE]= blank(),CUSTVEND[ACCTNO]= blank(),[On Hold]=1, FILTER(WO_HDR, WO_HDR[PARTNUMBER]<>"%kit%"))



Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Usates Member
Member

Re: Measure with "does not contain" and/or "is null"

I'm not sure how to post sample data effectively here.  It appears the issue to a True/False expression.

 

Capture.PNG

 

Thanks for your help.

Moderator v-yuezhe-msft
Moderator

Re: Measure with "does not contain" and/or "is null"

Hi @Usates,

Please use the following formula instead, replace tablename with your own table.

WO on Hold Count = CALCULATE(DISTINCTCOUNT(WO_HDR[Work Order#]),WO_HDR_STATUS[COMPLETED_DATE]= blank(),CUSTVEND[ACCTNO]= blank(),FILTER(tablename,tablename[On Hold]=1), FILTER(WO_HDR, WO_HDR[PARTNUMBER]<>"%kit%"))



Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
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

Highlighted
Usates Member
Member

Re: Measure with "does not contain" and/or "is null"

Perfect!  Thank you so much!

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 329 members 3,185 guests
Please welcome our newest community members: