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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Earl40
Helper I
Helper I

Custom column to extract part of the text

I have  a file that has a name column that contains 2 type of text before the actual name. All items will have (AB/CF) infront (used X;s to represent the name) but some will also have USA - after. Is it possible to create a custom column and have a dax formula remove  the (AB/CF) from all the names but also remove USA - where applicable? Sample screenshot below

 

Thank You in advance

 

Earl40_0-1701985464263.png

 

2 ACCEPTED SOLUTIONS
khaledHabib90
Resolver II
Resolver II

The easier solution would be to use power query

1- duplicate the column if you want to keep the original form of the data

2- perform 2 replace operations in power query , first replace the (AB/CF) with blank then USA-

Add spaces before and after as appropriate so that they are removed with the replace operations

 

If my reply helped you solve your problem please accept this as the solution 🙂

View solution in original post

v-tianyich-msft
Community Support
Community Support

Hi @Earl40 ,

 

If you want to achieve this with DAX, you can try

Measure = IF(CONTAINSSTRINGEXACT(MAX('Table'[Original Name]),"(AB/CF) USA-"),SUBSTITUTE(MAX('Table'[Original Name]),"(AB/CF) USA-",""),IF(CONTAINSSTRINGEXACT(MAX('Table'[Original Name]),"(AB/CF)"),SUBSTITUTE(MAX('Table'[Original Name]),"(AB/CF)",""),0))

 

vtianyichmsft_0-1702372901085.png

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

4 REPLIES 4
Ahmedx
Super User
Super User

pls try this

Screenshot_2.png

Bibiano_Geraldo
Resolver I
Resolver I

Try the following code:

CustomColumn = SUBSTITUTE(SUBSTITUTE([Your_Column_Name], "(AB/CF)", ""), "USA - ", "")

 

 

v-tianyich-msft
Community Support
Community Support

Hi @Earl40 ,

 

If you want to achieve this with DAX, you can try

Measure = IF(CONTAINSSTRINGEXACT(MAX('Table'[Original Name]),"(AB/CF) USA-"),SUBSTITUTE(MAX('Table'[Original Name]),"(AB/CF) USA-",""),IF(CONTAINSSTRINGEXACT(MAX('Table'[Original Name]),"(AB/CF)"),SUBSTITUTE(MAX('Table'[Original Name]),"(AB/CF)",""),0))

 

vtianyichmsft_0-1702372901085.png

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

 

khaledHabib90
Resolver II
Resolver II

The easier solution would be to use power query

1- duplicate the column if you want to keep the original form of the data

2- perform 2 replace operations in power query , first replace the (AB/CF) with blank then USA-

Add spaces before and after as appropriate so that they are removed with the replace operations

 

If my reply helped you solve your problem please accept this as the solution 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors