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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

CONTAINS function (DAX)

I created a column that shows if an 'agent' in a device is broken. However, I want to exclude devices where device name contains "ESX" or "Appliance" or the Operating System contains "vSphere" or "Hpux" or "solaris" from the logic I will apply for broken agents. I used a NOT (CONTAINS(...)) function to do this (in orange below). Is this accurate?
 
The highlighted portion (in orange) below:
 
 
IF(AND('Server&VDI'[Data Source]="Falcon",NOT(CONTAINS('Server&VDI','Server&VDI'[Operating system],"Solaris",'Server&VDI'[Operating system],"vSphere",'Server&VDI'[Operating system],"HPUX",'Server&VDI'[Device Name],"Appliance",'Server&VDI'[Device Name],"ESX"))),IF(AND(DATEDIFF('Server&VDI'[Falcon Scan Date ],'Server&VDI'[Maximum],DAY)>=15,DATEDIFF('Server&VDI'[Maximum],[LatestDate],DAY)<=60),"Broken Agent"))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

You can use DAX to achieve it with the help of function FIND (case-sensitive)or SEARCH (case-insensitive)as below screenshot:

GoodorBrokenAgent = if(SEARCH("ESX",'Server&VDI'[Device Name],1,0)>0||SEARCH("Appliance",'Server&VDI'[Device Name],1,0)>0
||SEARCH("Solaris",'Server&VDI'[Operating system],1,0)>0||SEARCH("vSphere",'Server&VDI'[Operating system],1,0)>0
||SEARCH("vSphere",'Server&VDI'[Operating system],1,0)>0,"Broken Agent","Good Agent")

contains.JPG

Best Regards

Rena

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous,

You can use DAX to achieve it with the help of function FIND (case-sensitive)or SEARCH (case-insensitive)as below screenshot:

GoodorBrokenAgent = if(SEARCH("ESX",'Server&VDI'[Device Name],1,0)>0||SEARCH("Appliance",'Server&VDI'[Device Name],1,0)>0
||SEARCH("Solaris",'Server&VDI'[Operating system],1,0)>0||SEARCH("vSphere",'Server&VDI'[Operating system],1,0)>0
||SEARCH("vSphere",'Server&VDI'[Operating system],1,0)>0,"Broken Agent","Good Agent")

contains.JPG

Best Regards

Rena

amitchandak
Super User
Super User

As per doc. Contains means all values

https://docs.microsoft.com/en-us/dax/contains-function-dax

 

You have use search in dax or  https://docs.microsoft.com/en-us/powerquery-m/list-containsany in M

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
Greg_Deckler
Community Champion
Community Champion

This seems eerily similar to another question that was asked on this site a few days ago. In answer to your current question I believe the answer is "No, you cannot use CONTAINS to do what you want to do". The reason is that CONTAINS searches for the specified text within the entire value of the column, it does not do partial matches in values of columns.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks Greg! What function should I use instead?

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.