Equivalent to Joining tables (SQL) in Excel?

Click For Summary

Discussion Overview

The discussion revolves around the methods of combining data from different sheets in Excel, akin to SQL table joins. Participants explore various techniques for calculating ratios and consolidating data, while also considering the advantages and disadvantages of using Excel versus SQL Server for data manipulation and reporting.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about performing calculations with data from different sheets in Excel, similar to SQL joins.
  • Several participants suggest using Excel's referencing capabilities and pivot tables to consolidate data from multiple sheets.
  • There are discussions about the practicality of exporting Excel data to SQL Server for more complex queries versus performing calculations directly in Excel.
  • Some participants argue that it is generally best practice to store data in SQL and use Excel for reporting and analysis.
  • Concerns are raised about connection issues between Excel and Microsoft Query, affecting the ability to perform queries on data from different sheets.
  • Participants discuss the limitations of pivot tables in performing calculations involving ratios of fields from different sheets.
  • One participant describes a method for calculating ratios using Excel formulas, while another suggests using the VLOOKUP function for one-to-one relationships between sheets.
  • There is mention of potential complications arising from one-to-many relationships in SQL queries, which may affect aggregation results.
  • Some participants propose nesting queries in SQL Server as a solution to combine results from separate queries.

Areas of Agreement / Disagreement

Participants express a mix of opinions regarding the best approach to combining data in Excel versus SQL Server. While some advocate for using Excel's capabilities, others emphasize the benefits of SQL for data management. The discussion remains unresolved with multiple competing views on the optimal method.

Contextual Notes

Participants highlight issues with data connections, the complexity of aggregating data in SQL, and the need for careful handling of relationships between data in different sheets. Specific limitations regarding the use of pivot tables and the handling of ratios are noted.

  • #31
WWGD said:
Ah, never mind. In case anyone is interested for the SQL format:
We want to compute the ratio SUM(f_1)/COUNT(f_2) , f1 in table 1 (T1), f2 in table 2 (T2);
f_12 a common field , over values in f_12 common to T1, T2.
This runs: EDIT

SELECT A/B FROM
( SELECT SUM(f_1) AS A
FROM T1 JOIN T2 on T1.f_12=T2.f_12 GROUP BY f_12) AS Table1
JOIN
(SELECT COUNT(f_2) AS B FROM T1 JOIN T2 ON T1.f_12=T2.f_12
GROUP BY f_12 ) AS Table2
ON Table1.f_12 =Table2.f_12
GROUP BY f_12

Sorry to all for dragging this along so far.

Have you found a solution yet?
I do sql in Excel now and then (ODBC) using some time sheets in the same file as tables, but also sometime sheets in differents files.
I know you can do simple join operations. See this link with some .xlsx examples and a ReadMe.txt file:
https://www.dropbox.com/sh/awoes8lgpj76igb/AABZOAEq7pF36kIXKykn3PKga?dl=0

In file T_Queries, I put A and B in different columns and did A/B the old school Excel way in a formula but you can play around with more complex join queries and see how Excel handles it.. (Ribbon > Data > Connections > DoubleClick on Connection > Definition).
Those two queries use tables/sheets being in the same file (T_1_and_2.xlsx).

Another query, just for fun, uses tables/sheets being in 2 different files (T_1.xlsx and T_2.xlsx).
It's cool that one can use a virtual database of excel files being all over the place and query it using our dear friends SQL and ODBC!

Let us know it this helps a little in what you were trying to achieve.
 
Last edited:
  • Like
Likes   Reactions: WWGD
Computer science news on Phys.org
  • #32
Tokinabo said:
Have you found a solution yet?
I do sql in Excel now and then (ODBC) using some time sheets in the same file as tables, but also sometime sheets in differents files.
I know you can do simple join operations. See this link with some .xlsx examples and a ReadMe.txt file:
https://www.dropbox.com/sh/awoes8lgpj76igb/AABZOAEq7pF36kIXKykn3PKga?dl=0

In file T_Queries, I put A and B in different columns and did A/B the old school Excel way in a formula but you can play around with more complex join queries and see how Excel handles it.. (Ribbon > Data > Connections > DoubleClick on Connection > Definition)

Those two queries use tables/sheets being in the same file (T_1_and_2.xlsx).
Another query, just for fun, uses tables/sheets being in 2 different files (T_1.xlsx and T_2.xlsx).

Let us know it this helps a little in what you were trying to achieve.
Thanks. I was able to do it in SQL , but I had trouble using Microsoft query within Excel; somehow the connection was not working well ( despite the fact that the Wizard had no trouble sending data back-and-forth). Thanks for your refs., will check them out.
 

Similar threads

Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 51 ·
2
Replies
51
Views
6K
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K