+ Reply to Thread
Results 1 to 7 of 7

Table Relationship vs SQL Join

  1. #1
    Registered User
    Join Date
    12-15-2011
    Location
    Washington
    MS-Off Ver
    Excel 2013
    Posts
    39

    Table Relationship vs SQL Join

    I thought that creating a relationship between two tables in Power Pivot would allow me to select a column from Table A and a column from Table B and then see the corresponding items related per row, like a SQL join. I don't understand the logic as to why it doesn't work that way but it certainly doesn't. So what I figured I would do is join all of these tables together into one query and then put it into Power Pivot. It works well but surely there is a better way because this query is massive and annoying to maintain.

    Also, can anybody help me understand the logic of the table relationships? Are relationships just to have the ability to aggregate data?

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Table Relationship vs SQL Join

    To link two tables you need to have a key field.

    Table1 : Item_Code, Item_Description , Item_Color and so on

    Table2 : Sold_Item_Code, Sold_Price , Sold_Qty and so on

    Now your sql will be like this :

    Please Login or Register  to view this content.
    The key field being item_code from table1 and sold_item_code from table2.
    This would be a simple join.
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Registered User
    Join Date
    12-15-2011
    Location
    Washington
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Table Relationship vs SQL Join

    I'm sorry about that Xlbiznes, I don't think I explained my question well enough. I know all of the SQL I need but I'm trying to get Excel to show me similar output. I guess my question should be: How can I get Excel to show me the same output as a SQL join? So if I have Table A and B in Power Pivot, I want to join those into one one pivot table.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Table Relationship vs SQL Join

    Relationships only apply in the context of the data fields you have in place. Until you have data fields in the pivot table, you will effectively see a Cartesian product.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    12-15-2011
    Location
    Washington
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Table Relationship vs SQL Join

    Thanks romperstomper. What I'm finding is that for a pivot table in which there is no data field in the "Values" quadrant, a "joined" type of table is not possible. Drop a data field into the "Values" and of course it aggregates and gets rid of anything with no value. I guess I just don't see the logic that, without an aggregate, it will display every possible value from a column like in the picture attached.

    I apologize for the simplistic understanding and basic questioning but I am very new to set/data manipulation and am obviously missing some key logic concept somewhere.

    I should mention that the two tables are in the data model with a relation between ProductID
    pivot.png

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Table Relationship vs SQL Join

    Without a data field, PP has no context as to which table you want all records from and which should just return any related records, so you get all records from both rather than an inner join.

  7. #7
    Registered User
    Join Date
    12-15-2011
    Location
    Washington
    MS-Off Ver
    Excel 2013
    Posts
    39

    Re: Table Relationship vs SQL Join

    Well at least it makes sense now, thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pivot table not respecting relationship
    By wood923 in forum Excel General
    Replies: 8
    Last Post: 11-28-2014, 02:00 PM
  2. Replies: 0
    Last Post: 08-09-2013, 12:32 PM
  3. [SOLVED] relationship table
    By pankaj8219 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 01-07-2013, 09:33 AM
  4. Table relationship
    By ciprian in forum Access Tables & Databases
    Replies: 3
    Last Post: 08-31-2011, 07:24 AM
  5. Database table and relationship advise
    By newbie2305 in forum Access Tables & Databases
    Replies: 0
    Last Post: 07-05-2011, 07:09 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1