删除字符串中的前两个字符。

huangapple go评论72阅读模式
英文:

Power Query, Remove 1st 2 characters in string

问题

我有一列电话号码,由于代理人输入它们到数据库的方式不同,格式稍有不同。有些以0开头,有些以44(国家代码)开头。我找到了一个在线代码,帮助我删除字符串开头的0,但现在我尝试修改它以删除字符串开头的44,但出现了一些问题。

= Table.TransformColumns(
#"Renamed Columns",
{{
"telephone",
each if Text.Start(Text.From(_),2)="44" 
then 
""&Text.From(_) 
else _ 
}})

提前感谢您的任何帮助。

英文:

I have a column of telephone numbers in slightly different formats due to how the agents input them into the database. Some start with a 0 and some with 44 (country code). I have found a code online that has helped me remove the 0's at the start of the string but now I am trying to adapt this to remove the 44 at the beginning of the string and for some reason, it doesn't seem to want to play ball.

= Table.TransformColumns(
#"Renamed Columns",
{{
"telephone",
each if Text.Start(Text.From(_),2)="44" 
then 
""&Text.From(_) 
else _ 
}})

Thanks in advance for any assistance

答案1

得分: 2

Table.TransformColumns(#"Changed Type",{{"telephone",每个如果Text.Start(Text.From(),2)="44"则Text.RemoveRange(Text.From(),0,2)否则_ }})

英文:

This should work

Table.TransformColumns(#"Changed Type",{{"telephone",each if Text.Start(Text.From(_),2)="44" then Text.RemoveRange(Text.From(_),0,2) else _ }})

huangapple
  • 本文由 发表于 2023年6月15日 16:14:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480430.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定