Forum Discussion

Dunner2020's avatar
Dunner2020
Icon for Post Prodigy rankPost Prodigy
5 years ago
Solved

Duplicate primary key in dimension table

Hi there,

I have a data model which looks like as follow:

 

Two tables are connected through EpochHH column. EpochHH is the unique number to represent the half-hour time slot in any given date. I want to create a new column in Table 2 that sum up Raw GI value occured in same EpochHH. To create a column, first I used the merge queries option in the power query editor to bring the Raw GI column in Table 2. I brought it the Raw GI value in Table 2 as shown in figure:

 

However, when I click on apply and close option, it throws following option:

 

I checked the Table 2 and it does not contain duplicate value of 110323. I am not sure how to fix the issue. Could you please help me in fixing the issue?
File can be download from here 

 

  • Dunner2020When you merge the table, it creates multiple instances of the primary key, to join the table, hence making it many to many relationship.

    To bring column from many side of the relationship to 1 side, you can simply use Calculated Column and an aggregated function.

    You can try this. Go to Table 2. Click New Column and paste this:

    Raw GI =
    CALCULATE(
    SUM('Table 1'[Raw GI]
    )
    )

    Let me know if this solves your problem.

1 Reply

  • Dunner2020When you merge the table, it creates multiple instances of the primary key, to join the table, hence making it many to many relationship.

    To bring column from many side of the relationship to 1 side, you can simply use Calculated Column and an aggregated function.

    You can try this. Go to Table 2. Click New Column and paste this:

    Raw GI =
    CALCULATE(
    SUM('Table 1'[Raw GI]
    )
    )

    Let me know if this solves your problem.