+ Reply to Thread
Results 1 to 4 of 4

Pivot Table combining two data sets

  1. #1
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Pivot Table combining two data sets

    I have two different sets of data (2 worksheets in the same workbook) that I want to be combined into a single pivot table.

    For the sake of this example, let's say that Country is the column that is in both sets of data.
    How do I get the pivot table to show a sum of a column from each data set based on Country?

    I am not familiar with Data Models or relationships.

    See attachment.
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Pivot Table combining two data sets

    PQ method:

    1. Load both to PQ (Get & Transform) as connection only.
    2. Then add blank query with following as source.
    Please Login or Register  to view this content.
    3. Convert the resulting list to table and then change type to Text and rename to "Country".

    This will serve as dimension table to tie two fact tables together.
    Load all queries into data model.

    Now in Data ribbon tool -> Data tools -> Relationships. New.

    Pick original table prefixed with Data Model Table. Add it's country column as foreign.

    Pick Data Model Table that was created from blank query as Related table, Country as Primary.
    0.JPG

    Do the same for the other original table.

    Insert Pivot -> Use this workbook's Data Model.

    Use column from Query1 (created from blank) as row label. And then add other columns from each respective table into value field.
    1.JPG

    Or you can create Country table in Excel sheet and use that as dimension table.
    Attached Files Attached Files
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  3. #3
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Pivot Table combining two data sets

    Thanks CK. Rep added.

    I'm going to have to take some time to review this further.

    Is this request not a standard use of Excel? Seems complex even for my simple sample.

    The actual sheet has multiple fields that will be placed in the ROWS area, and the same for COLUMNS and I can imagine the complexity increasing exponentially when trying to add more things in.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Pivot Table combining two data sets

    You are welcome

    It's not that complicated really. It just looks that way.

    In data model for Pivot Tables, or any sort of data analysis/reporting. You'd want dimension tables that connect different fact tables.
    Most commonly Star Schema or Fact Constellation Schema (collection of Star Schema).

    Dimensions are tables that hold descriptive attributes related to fact data and should be one to many relationship to fact table.

    So in this case, unique list of country becomes the dimension table, which connects two separate tables based on it.

    See link below for detailed explanation on Star Schema (your case is simple Fact Constellation Schema).
    https://docs.microsoft.com/en-us/pow...ce/star-schema

    I created the dimension table in PQ, but you can do the same in worksheet as well.

+ 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. Problem with Pivot table drawing two sets of data
    By faodavid in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-03-2018, 08:20 AM
  2. Connecting slicers from different data sets using table format (not by creating pivot)
    By karthikgmk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2016, 01:37 PM
  3. Connecting slicers from different data sets using table format (not by creating pivot)
    By karthikgmk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-17-2016, 12:36 PM
  4. Pivot table to compare two data sets
    By Mashhead in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 12-19-2014, 07:56 AM
  5. TrimMean of Pivot Table data sets
    By olagaton in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 09-04-2013, 09:10 AM
  6. Linking multiple pivot table filters that are from different data sets
    By jph89 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2012, 07:04 PM
  7. Replies: 2
    Last Post: 05-21-2012, 10:56 AM

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