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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
samdep
Advocate II
Advocate II

Remove leading 1 (country code) in phone number in PQ when it appears

Hi All,

 

I was wondering if someone could help me with the code in Power Query (using the trim function?) to remove the leading 1 (or country code) from phone numbers... It's present in some records, but not all, so I'm in need of some sort or leftstrip type of conditional statement -- as the presence of the 1 is impacting my join/merge. 

 

Thanks in advance! 

3 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Try this:

RemoveOne = Table.AddColumn(PreviousStepName, "Truncated", each if Text.StartsWith([PhoneNumberColumn], "1") then Text.RemoveRange([PhoneNumberColumn], 0) else [PhoneNumberColumn])

 

--Nate

View solution in original post

Anonymous
Not applicable

No need for the parentheses after the "if" in this case-you can remove them. But you DO need a final "else" clause:

each if Text.StartsWith([Client_Number__c],"1") then Text.RemoveRange([Client_Number__c],0) else if
[Client_Number__c] = "" then ""

else [Client_Number_c]

--Nate

 

View solution in original post

Anonymous
Not applicable

your final conditional has to be else, not else if.

 

--Nate

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Try this:

RemoveOne = Table.AddColumn(PreviousStepName, "Truncated", each if Text.StartsWith([PhoneNumberColumn], "1") then Text.RemoveRange([PhoneNumberColumn], 0) else [PhoneNumberColumn])

 

--Nate

@Anonymous thanks so much, this worked perfectly! One follow-up, I am getting an error for fields where the phone number is blank in my new conditional column, so I assume a nested if/then should solve for that --

 

each if Text.StartsWith([Client_Number__c],"1") then Text.RemoveRange([Client_Number__c],0) else if(
[Client_Number__c] = "" then "")  

 

The second 'then' seems to be producing an error - but the error is 'Token RightParen expected', so I'm not sure what the issue is. Appreciate any feedback you/anyone may have. thx!

Anonymous
Not applicable

your final conditional has to be else, not else if.

 

--Nate

Anonymous
Not applicable

No need for the parentheses after the "if" in this case-you can remove them. But you DO need a final "else" clause:

each if Text.StartsWith([Client_Number__c],"1") then Text.RemoveRange([Client_Number__c],0) else if
[Client_Number__c] = "" then ""

else [Client_Number_c]

--Nate

 

Anonymous
Not applicable

@samdep 
Have you solved? If not, you might want to share a sample data and expected output.

 

Paul Zheng _ Community Support Team

AlB
Community Champion
Community Champion

Hi @samdep 

Do you want to show some examples to clarify when you want to remove the 1 and when not?

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.