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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
memote1
Helper I
Helper I

Split by Positions when positions are in 3 separate columns

Hello!

 

I have a column I am trying to split into 6 columns based on position, since there are repeating instances of some delimiters, the instance number isn't always the same, and some are missing. I was able to determine the positions for splitting, now in 4 columns, but can't get them into a list to use Splitter.SplitTextByPosition.

 

The source data is publicy posted. I attempted to split by line break, carriage return and tab as in this article, with no luck. 

 

Source Data Example

Provider Name, City, State, ZipSpecialityCredential LicenseNPIAccred LevelF=Full L=LimitedEff. DateExp. Date
Abbe, Hannah   Mountain View Pain Center 63 N Quebec St Ste 300 Denver,CO 80230 (720) 749-5599Pain ManagementPA PA790910833601841 4/27/20247/31/2027
Abbott, Timothy W Mountain View Pain Center 15901 E Briarwood Cir, #150 Aurora,CO 80916 (720) 749-5599Pain ManagementPA PA292310231522121 12/19/20247/31/2027
Abercrombie, Chad E Alliance Health Partners 3920 N. Union Blvd, Suite 160 Colorado Springs,CO 80907 (719) 632-4754ChiropracticsDC CHR377310939179731 11/17/20007/31/2025
Abernethy, Kimberly A N/A 10093 W 100Th Pl Westminster,CO 80021Family MedicineDO DR43875*12352100482 6/12/20241/31/2027
Abernethy, Kimberly A Concentra Broomfield 290 Nickel Street Broomfield,CO 80020 Family MedicineMD DR4387512352100481 12/10/20237/31/2026

 

Desired Result

Provider NameCompanyAddressStateZipPhoneSpecialityCredentialLicenseNPIAccred LevelF=Full L=LimitedEff. DateExp. Date
Abbe, HannahMountain View Pain Center63 N Quebec St Ste 300 Denver,CO 80230CO80230(720) 749-5599Pain ManagementPAPA79091.08E+091 4/27/20247/31/2027
Abbott, TimothyW Mountain View Pain Center15901 E Briarwood Cir, #150 Aurora,CO 80916CO80916(720) 749-5599720) 749-5599PAPA29231.02E+091 ########7/31/2027
Abercrombie, ChadE  Alliance Health Partners3920 N. Union Blvd, Suite 160 Colorado Springs,CO 80907CO80907(719) 632-4754ChiropracticsDCCHR37731.09E+091 ########7/31/2025
Abernethy, Kimberly  A N/A10093 W 100Th Pl Westminster,CO 80021 CO80021(970) 309-8649Family MedicineDODR43875*1.24E+092 6/12/20241/31/2027
Abernethy, KimberlyA Concentra290 Nickel Street Broomfield,CO 80020CO80020(303) 460-9339Family MedicineMDDR438751.24E+091 ########7/31/2026

 

Current M-Code

let
Source = Excel.CurrentWorkbook(){[Name="dnld"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Provider Name, City, State, Zip", type text}, {"Speciality", type text}, {"Credential", type text}, {"License", type text}, {"NPI", Int64.Type}, {"Accred Level", Int64.Type}, {"F=Full L=Limited", type text}, {"Eff. Date", type date}, {"Exp. Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Name Position", each Text.Length(Text.BeforeDelimiter([#"Provider Name, City, State, Zip"]," ",2))),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Address Position", each Text.PositionOfAny([#"Provider Name, City, State, Zip"],{"0","1","2","3","4","5","6","7","8","9"},0)),
#"Added Custom2" = Table.AddColumn(#"Added Custom1", "State Zip", each Text.PositionOf([#"Provider Name, City, State, Zip"],",",Occurrence.Last)),
#"Added Custom3" = Table.AddColumn(#"Added Custom2", "Phone Position", each Text.PositionOf([#"Provider Name, City, State, Zip"],"(",1))
in
#"Added Custom3"

 

Thank you!

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

Add this line to your code to create the list:

 

#"Added Custom4" = Table.AddColumn(#"Added Custom3", "Splitter List", each Splitter.SplitTextByPositions(
            {0} & List.LastN(Record.FieldValues(_),4))([#"Provider Name, City, State, Zip"]))

 

And, as a suggestion, instead of reading it in as an Excel table, and taking a chance on unwanted transformations caused by Excel, I would read the `csv` file directly:

 

Source = Csv.Document(File.Contents("full_path_to_file\export.csv"),[Delimiter=",", Columns=9, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Provider Name, City, State, Zip", type text}, {"Speciality", type text}, {"Credential", type text}, {"License", type text}, {"NPI", Int64.Type}, {"Accred Level", Int64.Type}, {"F=Full L=Limited", type text}, {"Eff. Date", type date}, {"Exp. Date", type date}}),
...

 

Also, you will need to build in some error checking.

 

If you are missing a component (eg: phone number; street address, etc) your Position finder will return incorrect results.

View solution in original post

2 REPLIES 2
ronrsnfld
Super User
Super User

Add this line to your code to create the list:

 

#"Added Custom4" = Table.AddColumn(#"Added Custom3", "Splitter List", each Splitter.SplitTextByPositions(
            {0} & List.LastN(Record.FieldValues(_),4))([#"Provider Name, City, State, Zip"]))

 

And, as a suggestion, instead of reading it in as an Excel table, and taking a chance on unwanted transformations caused by Excel, I would read the `csv` file directly:

 

Source = Csv.Document(File.Contents("full_path_to_file\export.csv"),[Delimiter=",", Columns=9, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Provider Name, City, State, Zip", type text}, {"Speciality", type text}, {"Credential", type text}, {"License", type text}, {"NPI", Int64.Type}, {"Accred Level", Int64.Type}, {"F=Full L=Limited", type text}, {"Eff. Date", type date}, {"Exp. Date", type date}}),
...

 

Also, you will need to build in some error checking.

 

If you are missing a component (eg: phone number; street address, etc) your Position finder will return incorrect results.

Thank you so much!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.