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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
KelvinMorel
Helper II
Helper II

Adding column from another Excel source

Hi all,

Salesmen of the company need to fill in a Excel list for each event they make, so we have multiple Excel files. Here the "problem" I'm having, I would like to "merge" all those files in one but in this case I would like to only add the column with results.

 

Files are something like following:

File 1

QuestionsAnswers
Q A1
Q B2

File 2

QuestionsAnswers
Q A3
Q B4

 

Merged File should be something like following

QuestionsAnswersAnswers
Q A13
Q B24

 

Is something like this possible?

Cheers

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @KelvinMorel, if you want to make it dynamic - you can do it this way:

 

Lets assume you have such files in same folder, they looks like this and you have questions and answers stored in Sheet1 in each file:

 

File1

dufoq3_1-1715001251081.png

 

File2

dufoq3_2-1715001284351.png

 

Result

dufoq3_0-1715001219333.png

 

Change folder addres in Source step:

let
    Source = Folder.Files("c:\Downloads\PowerQueryForum\KelvinMorel\"),
    FilteredExcelFiles = Table.SelectRows(Source, each Text.StartsWith([Extension], ".xls")),
    BinaryToTable = Table.TransformColumns(FilteredExcelFiles, {{"Content", each Excel.Workbook(_, true){[Name = "Sheet1"]}[Data], type table}}),
    CombinedTables = Table.Combine(BinaryToTable[Content]),
    GroupedRows = Table.Group(CombinedTables, {"Questions"}, {{"All", each 
        [ a = Table.RemoveColumns(Table.FirstN(_, 1), {"Answers"}),
          b = List.Accumulate({0..List.Count([Answers]) -1}, a, (s,c)=> Table.AddColumn(s, "Answer" & Text.From(c+1), (x)=> [Answers]{c}, type text))
        ][b], type table}}),
    CombinedAll = Table.Combine(GroupedRows[All])
in
    CombinedAll

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @KelvinMorel, if you want to make it dynamic - you can do it this way:

 

Lets assume you have such files in same folder, they looks like this and you have questions and answers stored in Sheet1 in each file:

 

File1

dufoq3_1-1715001251081.png

 

File2

dufoq3_2-1715001284351.png

 

Result

dufoq3_0-1715001219333.png

 

Change folder addres in Source step:

let
    Source = Folder.Files("c:\Downloads\PowerQueryForum\KelvinMorel\"),
    FilteredExcelFiles = Table.SelectRows(Source, each Text.StartsWith([Extension], ".xls")),
    BinaryToTable = Table.TransformColumns(FilteredExcelFiles, {{"Content", each Excel.Workbook(_, true){[Name = "Sheet1"]}[Data], type table}}),
    CombinedTables = Table.Combine(BinaryToTable[Content]),
    GroupedRows = Table.Group(CombinedTables, {"Questions"}, {{"All", each 
        [ a = Table.RemoveColumns(Table.FirstN(_, 1), {"Answers"}),
          b = List.Accumulate({0..List.Count([Answers]) -1}, a, (s,c)=> Table.AddColumn(s, "Answer" & Text.From(c+1), (x)=> [Answers]{c}, type text))
        ][b], type table}}),
    CombinedAll = Table.Combine(GroupedRows[All])
in
    CombinedAll

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Anonymous
Not applicable

in excel we can do this with the help of vlookup from the another workbook  and in power query we can merge both files and expand only answers columnsScreenshot (32).png

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors