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
SantoshKumar
Employee
Employee

Extract Text from a string from each row in a column

Hi All,

 

I have a Column which contains data as below:

TagsExpected_New_Column
 Compulsion Games; GACCYellow; Gaming Accessibility;  MAS2.4.7; TP3; Accessibility; MAS2.4.7
Accessibility;  GACCYellow; Gaming Accessibility;  MAS2.4.3; TP3; Compulsion Games;MAS2.4.3
Accessibility;  GACCLime; Gaming Accessibility;  MAS4.1.2; TP3;  Compulsion Games;MAS4.1.2
Accessibility; Compulsion Games; GACCLime; Gaming Accessibility;  MAS4.1.2; TP3; MAS4.1.2
Accessibility;   MAS1.4.10; TP3;  Compulsion Games; GACCYellow; Gaming Accessibility;MAS1.4.10
 Compulsion Games; GACCLime; Gaming Accessibility;  MAS2.4.3; TP3; Accessibility; MAS2.4.3
Accessibility;  Compulsion Games; GACCYellow; Gaming Accessibility;  MAS2.4.3; TP3; MAS2.4.3
Accessibility;  GACCLime; Gaming Accessibility; MAS4.1.2; TP3; MAS4.1.2

 

I was not able to use Delimeter or Trim, LEFT, RIGHT,SUBSTITUTE etc to get my expected output.

Can anyone provide any DAX query to create new column as shown above. 

 

thanks

Santosh

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @SantoshKumar ,

 

 

Create a Calculated Column

 

Column = 
var a = SEARCH("MAS",'Table'[Tags],,999)
var b = SEARCH(";",'Table'[Tags],a,999)
var c = MID('Table'[Tags],a,b-a)

RETURN
c

 

1.jpg

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

 

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @SantoshKumar ,

 

 

Create a Calculated Column

 

Column = 
var a = SEARCH("MAS",'Table'[Tags],,999)
var b = SEARCH(";",'Table'[Tags],a,999)
var c = MID('Table'[Tags],a,b-a)

RETURN
c

 

1.jpg

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

 

ryan_mayu
Super User
Super User

@SantoshKumar 

please try this. I found the common of the part that you want is starting from MAS and before "TP" . It this is just an coincidence. Then this solution does not work.

Column = 
VAR a=find("MAS",'table'[Tags],1)
VAR b=find("TP",'table'[Tags],a)
return mid('table'[Tags],a,b-a-2)

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu 
Thanks for your response but TP will not be always available after MAS for this case. i got the solution with the use of Search and MID option.

Greg_Deckler
Super User
Super User

@SantoshKumar - Sure, use SEARCH or FIND to get the position of MAS. Use that starting position to then SEARCH or FIND for the next semi-colon. Use MID to get the text between those two positions.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.