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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
noizivision
Frequent Visitor

Trying to find the best way to change column text when it starts with a phone number

I have a column that is a bunch of mismatch information, and is delimited by " - ".  Luckily, some of it is fairly consistent, like I know some have a phone number at the start that I would like to remove (some with dashes and some without), so for those, I would like to delete using the delimiter, but others I need to keep the information before the delimiter.

For the ones without dashes, I was thinking I could do something like this:

 

#"Remove Starting Phone Number" = Table.ReplaceValue(#"Sorted Rows", each If Value.Is(Text.BeforeDelimiter([Assignee], " - "), Int64.Type) then Text.BeforeDelimiter([Assignee], " - ") else [Assignee], Text.AfterDelimiter([Assignee], " - "), Replacer.ReplaceText, {"Assignee"})

 

but I'm getting a Token comma expected error. I’ve also tried Text.StartsWith, but no go.  I think my logic is a little flawed…I’ve got a bit of a brain fog going on, so any help to accomplish this would be greatly appreciated.

1 ACCEPTED SOLUTION
noizivision
Frequent Visitor

Well, that's embarrassing...it turns out that error, and the reason the Text.StartsWith didn't work was due to If instead of if...case sensitivity. So, this now works:

#"Remove 555" = Table.ReplaceValue(#"Sorted Rows", each if Text.Start([Assignee], 3) = "555" then Text.Start([Assignee], 13) else "___", "", Replacer.ReplaceText, {"Assignee"})

Not the best way to do it, but at least it works for my current needs.  I'll probably change it to remove up to the delimiter for those records, and make my "else" to be more definitive, to be cleaner.

View solution in original post

4 REPLIES 4
noizivision
Frequent Visitor

Well, that's embarrassing...it turns out that error, and the reason the Text.StartsWith didn't work was due to If instead of if...case sensitivity. So, this now works:

#"Remove 555" = Table.ReplaceValue(#"Sorted Rows", each if Text.Start([Assignee], 3) = "555" then Text.Start([Assignee], 13) else "___", "", Replacer.ReplaceText, {"Assignee"})

Not the best way to do it, but at least it works for my current needs.  I'll probably change it to remove up to the delimiter for those records, and make my "else" to be more definitive, to be cleaner.

don't worry, I didn't catch that either...

noizivision
Frequent Visitor

Sure, here's the sample data (assume over a hundred cases of each, with different names and numbers, except 555):

AssigneeContact
MOB002079 - McGartidy, FriankieMcGartidy, Frankie
555-325-1369 - DiRiendzi4DiRiendzi, Michael
Williards, Jeff - MOB004444Williards, Jeff
5553241345 - OMH45Samson, Rudolf
555-325-8466Jacobson, Pat
On Call Crew Leader - Brins, ChrisBrins, Chris
OMH 4 - Eckels, Verina Eckels, Verina 
Jacobs, JohnFuller, Mark

I hope to be able to ultimately get to this output:

AssigneeContact
McGartidy, FrankieMcGartidy, Frankie
DiRiendzi4 - DiRiendzi, MichaelDiRiendzi, Michael
Williards, JeffWilliards, Jeff
OMH45 - Samson, RudolfSamson, Rudolf
Jacobson, PatJacobson, Pat
On Call Crew Leader - Brins, ChrisBrins, Chris
OMH 4 - Eckels, Verina Eckels, Verina 
Jacobs, JohnFuller, Mark

Thank you so much!

lbendlin
Super User
Super User

Any chance you could post some sample data and expected results?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.