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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Rnaval
Post Patron
Post Patron

Need help combining 4 worksheets into one

I'm new to Power Query. Is it possible to combine 4 worksheets into one based on a single key such as IP Address? 

1 ACCEPTED SOLUTION

Hi @Rnaval ,

 

You can certainly automate this process to run daily. Since your merges are already functioning correctly, you are well positioned for automation. Power Query is designed to repeat all your steps, such as removing duplicates and merging, each time the query refreshes. Therefore, automation mainly involves setting up a consistent refresh schedule rather than changing your existing setup.

If you are using Microsoft Excel, you can configure the query to refresh automatically when the file is opened, ensuring your master file always reflects the latest data. This solution works well if someone opens the file daily. If you require the process to run independently, you may need to use an external tool, such as a scheduled task or a cloud-based flow, to open and refresh the file at regular intervals.

For a fully automated, hands-off process, Microsoft Power BI is often preferable. Once your query is built, you can publish it and schedule daily refreshes, providing a reliable solution for ongoing operations.

Regardless of the method chosen, ensure that your source files remain consistent in terms of file names, locations, column structures, and the IP Address field format. Your duplicate handling logic in Power Query will continue to operate automatically with each refresh. At this stage, you do not need to modify your query logic simply determine the most suitable way to trigger the daily refresh based on your automation needs.

Thank you.

View solution in original post

10 REPLIES 10
cengizhanarslan
Super User
Super User

Step 1) Merge the queries

In Power Query:

  1. Select your main query

  2. Choose Home → Merge Queries

  3. Select the second worksheet

  4. Click IP Address in both tables

  5. Choose the join type

Usually you want:

  • Left Outer → keep all rows from the first sheet, bring matching data from the second

Repeat for the 3rd and 4th worksheets.

 

Step 2) Expand the merged tables

After each merge, Power Query will create a nested table column.

Click the expand icon and select the columns you want to bring in.

 

Step 3) Load the final result

Once all merges are done, click Close & Apply (Power BI) or Close & Load (Excel).

_________________________________________________________
If this helped, ✓ Mark as Solution | Kudos appreciated
Connect on LinkedIn | Follow on Medium
AI-assisted tools are used solely for wording support. All conclusions are independently reviewed.
pcoley
Continued Contributor
Continued Contributor

@Rnaval sure you can!

Yes, absolutely — it's not only possible, it's one of the most common and powerful things Power Query does very well.

Since you're new to Power Query, I'll explain the two main ways to "combine" 4 worksheets, and which one you probably want when you mention "based on a single key such as IP Address":

 
Goal Use this Power Query feature What it does When to choose it
Stack rows on top of each other (same columns, more records)AppendPuts Sheet2 under Sheet1, Sheet3 under that, etc.You just want a big long list of all records
Join side-by-side (add columns from other sheets) using IP Address as the matching keyMergeLike VLOOKUP / XLOOKUP but for whole tables — brings matching data from other sheets into the main oneYou want to enrich one main sheet with info from the others using IP Address


Most people who say "combine based on a key like IP Address" actually mean Merge (joining horizontally by matching IP).

Quick Recommendation (most likely what you need)

Use Merge if the 4 sheets have different columns but share IP Address as the common identifier.

Example:

  • Sheet1 = Main list of IPs + basic info
  • Sheet2 = Usage stats by IP
  • Sheet3 = Location / Owner by IP
  • Sheet4 = Last scan date by IP

→ You want one big table with all columns, matched by IP Address.

Step-by-Step: Merge 4 Sheets by IP Address (Beginner-friendly)

  1. Open Excel → go to the Data tab → Get DataFrom Other SourcesBlank Query (or From File → From Workbook if you want to start from one sheet)

  2. In Power Query Editor, create 4 separate queries — one for each sheet:

    • Home → New SourceExcel Workbook (or just From File if already open)
    • Browse/select your file → choose Sheet1Transform Data
    • Rename this query to something clear like Sheet1_IPs
    • Repeat for Sheet2, Sheet3, Sheet4 → name them Sheet2_Usage, etc.

    Tip: Make sure IP Address column is the same data type in all sheets (usually Text). Right-click the column → Change TypeText.

  3. Decide your main / left table (usually the most complete one — let's say Sheet1_IPs).

  4. With Sheet1_IPs selected, go to Home tab → Merge QueriesMerge Queries as New (safer for beginners)

  5. In the merge dialog:

    • Top box = your current query (Sheet1_IPs)
    • Bottom box = choose the next sheet (e.g. Sheet2_Usage)
    • Click the IP Address column in both tables (they light up green)
    • Join Kind = Left Outer (keeps all rows from Sheet1, even if no match in Sheet2)
    • OK
  6. A new column appears (usually called Sheet2_Usage) → click the expand icon (two arrows)

    • Select only the columns you want from Sheet2
    • Uncheck "Use original column name as prefix" (cleaner)
    • OK
  7. Repeat steps 4–6 for the other two sheets:

    • Merge the result with Sheet3_...
    • Then merge again with Sheet4_...
  8. When finished → HomeClose & Load → choose To new worksheet

You now have one combined table where every IP from the main sheet has extra columns pulled from the other sheets (null if no match).

If you actually want to stack them vertically (Append)

Only do this if all 4 sheets have almost identical columns (same names, same order is ideal).

  • Load all 4 sheets as separate queries
  • Select the first one → Home → Append QueriesAppend Queries as New
  • Choose the other 3 one by one (or select all three at once)
  • Close & Load

But since you mentioned "based on a single key such as IP Address", Merge is almost certainly what you're after.

I hope this helps. if so please mark it as a solution. kudos are welcome!

Regards, PColey 
I hope this helps.
Please Mark my post as a solution if it helped to resolve your issue.
Kudos are Welcome!
Please do let us know if you have any further queries.

Actually, I do see the third Merge query and I was able to remove duplicates from the 3 files that I merged prior to the close and load in order to end up with the correct total count. Question now is that is there a way to automate this power query so it happens daily? 

Hi @Rnaval ,

 

You can certainly automate this process to run daily. Since your merges are already functioning correctly, you are well positioned for automation. Power Query is designed to repeat all your steps, such as removing duplicates and merging, each time the query refreshes. Therefore, automation mainly involves setting up a consistent refresh schedule rather than changing your existing setup.

If you are using Microsoft Excel, you can configure the query to refresh automatically when the file is opened, ensuring your master file always reflects the latest data. This solution works well if someone opens the file daily. If you require the process to run independently, you may need to use an external tool, such as a scheduled task or a cloud-based flow, to open and refresh the file at regular intervals.

For a fully automated, hands-off process, Microsoft Power BI is often preferable. Once your query is built, you can publish it and schedule daily refreshes, providing a reliable solution for ongoing operations.

Regardless of the method chosen, ensure that your source files remain consistent in terms of file names, locations, column structures, and the IP Address field format. Your duplicate handling logic in Power Query will continue to operate automatically with each refresh. At this stage, you do not need to modify your query logic simply determine the most suitable way to trigger the daily refresh based on your automation needs.

Thank you.

Hi @Rnaval ,

 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Thank you.

This is resolved thanks to the help from the members on this thread.

Hi @Rnaval ,

Thank you @cengizhanarslan  for the response provided!

Has your issue been resolved? If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

Thank you.

Hi @Rnaval ,

 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Thank you.

I have 4 files - Master, Operating System, Scan Date and Logon ID. The master is my main file then I want to bring in a single column from each of the other files. I should end up with three columns added to the end of my Master file. I followed the steps above. However, I ended up with only a single additional column from the last sheet that I merged. The first two sheets' columns got overwritten I think. Somehow there is a step after merging the first sheet that I need in order to end up with 3 new columns.

Thank you so much, you have explained this so well! And yes it's the Merge option that I'm going to use. I'll try it this weekend and let you know how it goes.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.