Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Table Relatioship when there is Primary Key

I need to compare three tables dollar amounts. They do not have primary key since they come from spreadsheets and a DB table. I need to compared at a Customer ID, PO# level, Job Card and Manufacture ...
  • PaulDBrown's avatar
    PaulDBrown
    6 years ago

    Anonymous 

     

    You are getting the "amibguity" message when trying to create the relationships because the detail in the data generates "conflict" when setting up the independent slicers. (As I mentioned in my previous post, I actually added rows to the data you provided to avoid this in the example, based on your comment that the actual dataset would actually contain many more IDs etc...)

    To see what I mean, if you look at the dataset, there is only 1 customer id and the "Manufacture#" has single corresponding PO values.

    So depending on what the final dataset looks like, you can set up the model with a single lookup table in which you establish a single field as your "primary key" (though you have to be careful when removing duplicates to ensure you are not removing rows with disctinct values. As an example, if you removed duplicates from the customer id field, you would be left with a single row, which obviously doesn't reflect the nature of your data).

    Sticking strictly to the dataset you provided, you could have a model set up like this (the unique values - remove duplicates - is on the "Manufacture#"):

     

    and get this result:

     

    Having said all that, and taking into account that the difference between the tables is a timeframe (Initial Quote, before Billing, Final Cost), I would set up the model differently. Namely, I would add a column in each of your tables to identify the quote timeframe and then append the tables into a single table.

    1) add a column to each table identifying the quote timeframe:

     2) append all three tables into a single table of data:

     3) add Dim tables as in the example above + a new dim table for timeframe. The model should look like this:

     4) create a mesaure for the sum of Costs:

     

     

    Cost = SUM('Data Table'[Cost])

     

     

     

    5) And finally set up your matrix using the fields from the Dim tables (notice the "Quote Timeframe" in th column bucket)

     

    And here is the PBIX file for your reference:

    PBIX file Append Tables 

     

    Hope that helps!