Forum

Transform Specific ...
 
Notifications
Clear all

Transform Specific Worksheet into Table

15 Posts
3 Users
0 Reactions
141 Views
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Guys,

i have Excel worksheet like:

Screenshot_21.png

and now i have to get result:

Screenshot_22.png

The biggest problem i have to merge all values columns (value_1, value_2,value_3). 

How can i do this? 

Test1.xlsx - source data

MergedExample - expected result 

 

Please help,

Best,

Jacek

 
Posted : 09/10/2019 6:28 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Jacek,

You can append the tables. See file attached.

Mynda

 
Posted : 09/10/2019 7:41 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

o wow very nice approach,

thank you! 

Hmm ok but when i have to select multiple files like Test1 - like for example 50 from folder i would have to do one big transformation i think.
Using Merging columns and unpivoting them, can you help also with that? 

And furthermore, how can i add workbook source name to colum? (i would to take without extension = "xlsx"). 

I attached second worbkook - i need one more column here - workbook name. 

Best Wishes,
Jacek

 
Posted : 09/10/2019 11:36 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Ok i am addiny my trials with this as attachment.

I combined and transformed 2 tables and merged columns for Values but i do not know what should be next. 

Please help,
Jacek

 
Posted : 09/10/2019 11:52 am
(@mynda)
Posts: 4761
Member Admin
 

Ah, not all of the information was provided with your first question. I suspect there is more you haven't explained, like;

1. will each file in the folder have the exact same structure (columns, rows, sheets)?

2. will the data be formatted in Excel tables or named ranges, or just random unspecified ranges as per your first example file, in which case, how will Power Query know which cells you want to consolidate and which you want to exclude?

3. will each file also have data that is redundant as there was in your example file in the first few columns?

4. will each file have only one sheet containing data you want to get?

The second sample file, PQTEST.xlsx connects to external files that I don't have, therefore I cannot see the query or data. Please provide the source files as well.

Mynda

 
Posted : 09/10/2019 10:32 pm
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Mynda,

thanks for questions!

1. Yes, exact structure

2. There is no tables and ranges. PQ will use Columns without structure

3. Yes, the structure is the same and everywhere i have to take only specific columns

4. yes, only one sheet. 

External files in attachment. 

In PQTEST.xlsx i am just trying to merge Test1 and Test2 from the same folder. 

 
Posted : 10/10/2019 3:11 am
(@mynda)
Posts: 4761
Member Admin
 

Thanks for providing the sample files. You'll see in the attached I used Get Files from Folder and that you need to duplicate the final query two more times so you have 3 queries, one for each table in the files; UpdatedName, NameAdded and NameDeleted.

The file name is automatically retained when you get files from a folder, so nothing extra to do there.

Mynda

 
Posted : 10/10/2019 7:02 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

o wow thank you very much!

Few questions:

1. = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true) and action "Filtered hidden files".

How did you do this? 

2. When you were creating 4 queries : "NameAdded", "NameDeleted" you wre copying queries manually and deleted other files created with them together? 

(not necessery one)

 

Best,

Jacek

 
Posted : 10/10/2019 10:03 am
(@mynda)
Posts: 4761
Member Admin
 

1. This is done by Power Query automatically when you get files from a folder.

2. The first query under the 'Other Queries' folder is created automatically when you get the files from a folder. I renamed it, then duplicated it two more times for the NameDeleted and UpdatedName queries. Then deleted the columns from each query that weren't relevant.

 
Posted : 10/10/2019 11:11 pm
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

thank you Mynda. 

 
Posted : 11/10/2019 12:04 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Mynda,

one more thing. 
I want to input folder path into cell and pass it to power query. 

Can you help with this? 

Best,
Jacek

 
Posted : 11/10/2019 10:18 am
(@catalinb)
Posts: 1937
Member Admin
 

You can create a table with a single row that contains your folder path.

In power query, add a new line using Advanced Editor with:

FolderName = Excel.CurrentWorkbook(){[Name="Table1Name"]}[Content]{0}[Column Name],

Rplace the hardt yped path from the query with this parameter name:

Source=Folder.Files(FolderName)

 
Posted : 11/10/2019 12:07 pm
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Hi Catalin,

thank you. I tried to use what you provided but i have issues with that. 

Where exactly can i put this path? 

Can you please help and use my attached workbooks?

Please help,
Jacek

 
Posted : 05/11/2019 4:03 am
(@jaryszek)
Posts: 177
Reputable Member
Topic starter
 

Please help,

Jacek

 
Posted : 06/11/2019 5:27 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Jacek,

As mentioned, the cell that holds the path should be in a Table, not a regular cell.

Select L1:L2 and press Ctrl+T to create a table.

In the attached file, the table name is Table2, use it in query:

FolderName = Excel.CurrentWorkbook(){[Name="Table2"]}[Content]{0}[FolderPath],

Source=Folder.Files(FolderName)

 
Posted : 06/11/2019 2:26 pm
Share: