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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PeterDWP
Frequent Visitor

Struggling loading mutilpe text files into BI

Hi all I'm struggling here I'm new to BI but I have 800 ish text files, (in the current sample) all called head.txt each in a different folder, each file looks like this

 

Mode CFA drilling

start date 2016-06-24

start time 11:22:48

stop date 2016-06-24

stop time 13:27:00

job site 15D795

pile number 160A

maximum depth [cm] 1608

style 1

pile diameter [cm] 60

total concrete vol. [m³] 6.1225

no. imp. (concrete pump) 155

liter/imp. (concrete pump) 39.5

auger length [cm] 100

concrete vol. [m³] 5.727

over consumption [%] 26.0

 

I can get the data to load into two columns but the first column just repeats the labels, I wish to transpose this into a table with 16 columns i.e. mode ..to.. over consumption, what I get is a single row with no consolidation

 

Any ideas??

1 ACCEPTED SOLUTION

@PeterDWP

 

I noticed that there are 16 rows in each log. We can add an index column start from 10000 and with 625 increment in Query Editor.

Struggling loading mutilpe text files into BI_2.jpg

Then divide by 10000 and round down for this column in Transform tab.

Struggling loading mutilpe text files into BI_7.jpg

Now the table will like below.

Struggling loading mutilpe text files into BI_8.jpg

Select column1 and pivot it with following settings.

Struggling loading mutilpe text files into BI_5.jpg

At last, delete the first Index column.

Struggling loading mutilpe text files into BI_6.jpg

Below is the completed Power Query which can be pasted into Advanced Editor.

let
    Source = Excel.Workbook(File.Contents("C:\head.xlsx"), null, true),
    head_Sheet = Source{[Item="head",Kind="Sheet"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(head_Sheet,{{"Column1", type text}, {"Column2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type"),
    #"Added Index" = Table.AddIndexColumn(#"Promoted Headers", "Index", 10000, 625),
    #"Divided Column" = Table.TransformColumns(#"Added Index", {{"Index", each _ / 10000, type number}}),
    #"Rounded Down" = Table.TransformColumns(#"Divided Column",{{"Index", Number.RoundDown, Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Rounded Down", List.Distinct(#"Rounded Down"[Column1]), "Column1", "Column2"),
    #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
    #"Removed Columns"

Best Regards,

Herbert

View solution in original post

3 REPLIES 3
v-haibl-msft
Employee
Employee

@PeterDWP

 

Just to confirm, you can already load these text files into Power BI like following left table and you want to convert it to the right one?

Struggling loading mutilpe text files into BI_1.jpg

 

Best Regards,

Herbert

Yes thats correct, ive 800 plus text files all in indevidual folders and BI worked a treat loading its just this final tranposition I need to solve

 

P

@PeterDWP

 

I noticed that there are 16 rows in each log. We can add an index column start from 10000 and with 625 increment in Query Editor.

Struggling loading mutilpe text files into BI_2.jpg

Then divide by 10000 and round down for this column in Transform tab.

Struggling loading mutilpe text files into BI_7.jpg

Now the table will like below.

Struggling loading mutilpe text files into BI_8.jpg

Select column1 and pivot it with following settings.

Struggling loading mutilpe text files into BI_5.jpg

At last, delete the first Index column.

Struggling loading mutilpe text files into BI_6.jpg

Below is the completed Power Query which can be pasted into Advanced Editor.

let
    Source = Excel.Workbook(File.Contents("C:\head.xlsx"), null, true),
    head_Sheet = Source{[Item="head",Kind="Sheet"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(head_Sheet,{{"Column1", type text}, {"Column2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type"),
    #"Added Index" = Table.AddIndexColumn(#"Promoted Headers", "Index", 10000, 625),
    #"Divided Column" = Table.TransformColumns(#"Added Index", {{"Index", each _ / 10000, type number}}),
    #"Rounded Down" = Table.TransformColumns(#"Divided Column",{{"Index", Number.RoundDown, Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(#"Rounded Down", List.Distinct(#"Rounded Down"[Column1]), "Column1", "Column2"),
    #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
    #"Removed Columns"

Best Regards,

Herbert

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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