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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jessenewold
Frequent Visitor

Dax using IF and Contains

Hello, 

I've created the below to replace the name of the terminal ID i.e. CAD01-2006 with Dispatch etc. 

I have hundreds of terminals.  I want to be able to find all of the terminals that have "web" in the name and replace them with a new name.   Help is very much appreciated.  

 

dax for if.PNG

1 ACCEPTED SOLUTION
ERD
Community Champion
Community Champion

@jessenewold ,

You can try this approach:

Measure = 
IF (
    CONTAINSSTRING ( SELECTEDVALUE ( T4[TERMINAL ID] ), "$" ) = TRUE (),
    "MOBILE",
    SELECTEDVALUE ( T4[TERMINAL ID] )
)

ERD_0-1632325384584.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

4 REPLIES 4
jessenewold
Frequent Visitor

I want to find all terminal ID's that have $ in the name and name them "Mobile" in the Created Terminal Group column. Final all termianl ID's that have ABC in the name and name them "Center1" in the Created Terminal Group column.

Thank you.

TERMINAL IDCREATED TERMINAL GROUP
$1MOBILE
$3MOBILE
$5MOBILE
$6MOBILE
ABCpc150-037CENTER1
ABCpc150-038CENTER1
ABCpc150-039CENTER1
ABCpc150-040CENTER1
ABCpc150-041CENTER1
ABCpc150-042CENTER1
ERD
Community Champion
Community Champion

@jessenewold ,

You can try this approach:

Measure = 
IF (
    CONTAINSSTRING ( SELECTEDVALUE ( T4[TERMINAL ID] ), "$" ) = TRUE (),
    "MOBILE",
    SELECTEDVALUE ( T4[TERMINAL ID] )
)

ERD_0-1632325384584.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Thank you so very much - this is exactly what I was looking for. 

Greg_Deckler
Community Champion
Community Champion

@jessenewold Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.