Split Columns Width (Text File)

Hi DNA Team,

I run into an issue while splitting the data. I can easily split the data in excel by going to text to column -> Fixed width (adjust the size columns) but I would like to do it in PBI.

When I load the text file to Power Bi I can’t split the text into 22 columns.

let
Source = Csv.Document(File.Contents(“C:\Users\MWojnach\Documents\Project\Completed WIP Extract test.txt”),[Delimiter=":", Columns=1, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#“Changed Type” = Table.TransformColumnTypes(Source,{{“Column1”, type text}}),
#“Filtered Rows” = Table.SelectRows(#“Changed Type”, each not Text.Contains([Column1], “Total extern jobs”) and not Text.Contains([Column1], “Work in progress”) and not Text.Contains([Column1], “Total”) and not Text.Contains([Column1], “N/L acct”) and not Text.Contains([Column1], “General total”) and not Text.Contains([Column1], “Fin.year”) and not Text.Contains([Column1], “From”)),
#“Removed Duplicates” = Table.Distinct(#“Filtered Rows”),
#“Trimmed Text” = Table.TransformColumns(#“Removed Duplicates”,{{“Column1”, Text.Trim, type text}}),
#“Promoted Headers” = Table.PromoteHeaders(#“Trimmed Text”, [PromoteAllScalars=true]),
#“Changed Type1” = Table.TransformColumnTypes(#“Promoted Headers”,{{“Job no. Cat. T/S Parts Hours Hours am. 3rd-party Other Costs Tot.Costprice Type Invoices Customer Misc. Creat.date Chassisnr SP Description Mil.count Hrs.count Finished Closed S Operator”, type text}})
in
#“Changed Type1”

The loaded data is stored in a single column, I did apply filters to and remove duplicated to minimize the data and keep the data that I need. Then I trimmed the column but I can’t split it into 22 columns.

Even if I don’t promote headers I can’t see an option to split the column with width in Power bi.

textsplit.pbix (1.1 MB)

Could please advise how can I split the data into 22 columns.

Many thanks,

Matty

Hi @Matty. can you please upload your source data file as well? An extract from the PBIX, say using DAX Studio, may not regenerate the file in exactly the same layout as your original. I expect this will be of use to the forum members. As well, the same data in Excel spreadsheet would be useful as a comparison of your desired outcome.
Greg

Hi @Matty,

You can use the Split Column by Positions option for this type of transformation.
Might have to adjust the positions a little, just give it a go - I would say.

I hope this is helpful.

1 Like

@Greg
@Melissa
Thank you I will give ago :slight_smile:,

While being on my way to home, I was reading the below post https://p3adaptive.com/2016/03/power-query-fixed-width-magic/

ans I think it will solve the issue as @Melissa mentioned split by numbers of characters.

Personally I didn’t knew that there advance option in this option that I can split the column by various range :slight_smile:

I will keep you updated if I manage or fail :smiley:
finger :crossed_fingers:

Thank you

Matty

@Melissa

Thank you for advice and when I read the post and it worked :slight_smile:

https://p3adaptive.com/2016/03/power-query-fixed-width-magic/

The only issue I had was to count the position of columns. To get it correctly, I exported the data into excel to calculate the positions:

Once again for the hint :slight_smile:

Matty