Forum Discussion

Nethunt's avatar
Nethunt
Frequent Visitor
9 years ago
Solved

Combine same tables from different companies

In addition to message https://community.powerbi.com/t5/Desktop/Combine-same-tables-with-from-different-companies/m-p/198531/highlight/true#M87342 we have an issue / question.

 

In our situation we have 10 companies; but that shouldn't be a problem (I think).

Added a column in each (company)query (name query and company has to different - so far so good).

In our case the primary key of a table is YearWeek.

In the table itself this key is unique. However combined not (then there are 10 the same primary keys).

 

After applying the query changes I got of course the following message:

Column "YearWeek" in Table 001 contains a duplicate value "201601" and this is not allowed for columns on the one side of a many-to-one relationship or for coluns that are used as the primary key of a table.

 

What is the best way to add unique primary keys to each table or an other way to solve this ?

 

TIA for replying


  • Nethunt wrote:

    In addition to message https://community.powerbi.com/t5/Desktop/Combine-same-tables-with-from-different-companies/m-p/198531/highlight/true#M87342 we have an issue / question.

     

    In our situation we have 10 companies; but that shouldn't be a problem (I think).

    Added a column in each (company)query (name query and company has to different - so far so good).

    In our case the primary key of a table is YearWeek.

    In the table itself this key is unique. However combined not (then there are 10 the same primary keys).

     

    After applying the query changes I got of course the following message:

    Column "YearWeek" in Table 001 contains a duplicate value "201601" and this is not allowed for columns on the one side of a many-to-one relationship or for coluns that are used as the primary key of a table.

     

    What is the best way to add unique primary keys to each table or an other way to solve this ?

     

    TIA for replying


    Nethunt

    Roughly speaking, you can try to create a composite column like "company1_201601" and this column contains unique values in your case. What is the many table in this relationship? Usually a better practice is putting the '201601' in a calendar table which is connected to Table001 with the column dates. 

1 Reply

  • Eric_Zhang's avatar
    Eric_Zhang
    Icon for Microsoft Employee rankMicrosoft Employee

    Nethunt wrote:

    In addition to message https://community.powerbi.com/t5/Desktop/Combine-same-tables-with-from-different-companies/m-p/198531/highlight/true#M87342 we have an issue / question.

     

    In our situation we have 10 companies; but that shouldn't be a problem (I think).

    Added a column in each (company)query (name query and company has to different - so far so good).

    In our case the primary key of a table is YearWeek.

    In the table itself this key is unique. However combined not (then there are 10 the same primary keys).

     

    After applying the query changes I got of course the following message:

    Column "YearWeek" in Table 001 contains a duplicate value "201601" and this is not allowed for columns on the one side of a many-to-one relationship or for coluns that are used as the primary key of a table.

     

    What is the best way to add unique primary keys to each table or an other way to solve this ?

     

    TIA for replying


    Nethunt

    Roughly speaking, you can try to create a composite column like "company1_201601" and this column contains unique values in your case. What is the many table in this relationship? Usually a better practice is putting the '201601' in a calendar table which is connected to Table001 with the column dates.