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
BeraG
Frequent Visitor

Removing the text content of one column from another column

I am trying to remove the entire content of a text column from another column, e.g. removing " 10 episodes, 2018" from "Iyad Adi Kassar 10 episodes, 2018". The text in the column to be removed is the result of cleaning from the longer text in the previous column, which did not have clear delimiters and presented the problem of two or three names and other issues.

Now I have the two columns I wanted, and the text from the second should simply be eliminated from the first. I've tried with this line of code:

 

#"Added Custom Column1" = Table.AddColumn(#"Renamed Columns", "Character", each Text.Remove([Column4], [Episodes]))

 

This, however, gives me an error saying:

Expression.Error: The value isn't a single-character string.
Details:
Value= 10 episodes, 2018

BeraG_1-1678965069884.png

Any ideas? Thanks!

 

1 ACCEPTED SOLUTION
BeraG
Frequent Visitor

Thanks for the idea, Nate. While your solution still did not fit perfectly, because the original column has a less than regular content pattern, and the two space delimiters work well with three names, but not with two or four, I ended up adapting your code to the following:

Text.BeforeDelimiter([Column4], " ", {2, RelativePosition.FromEnd})

which works perfectly. Thanks once again!

View solution in original post

4 REPLIES 4
BeraG
Frequent Visitor

Thanks for the idea, Nate. While your solution still did not fit perfectly, because the original column has a less than regular content pattern, and the two space delimiters work well with three names, but not with two or four, I ended up adapting your code to the following:

Text.BeforeDelimiter([Column4], " ", {2, RelativePosition.FromEnd})

which works perfectly. Thanks once again!

Darn, I meant to tell you to use the RelativePosition.FromEnd parameter--that's what I get for answering without a computer!

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
HotChilli
Super User
Super User

Try Text.Replace() and use "" as the replacement text

watkinnc
Super User
Super User

Looks like you could do 

 

Table.AddColumn(PriorStepOrTableName, "NewText", each Text.BeforeDelimiter([Column4], " ", 2))

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

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
Top Kudoed Authors