Forum Discussion

RVBIBS's avatar
RVBIBS
Regular Visitor
3 years ago
Solved

Duplicate value error

Hej,

 

I have a issue with my data when i try to refresh.

I get the error code

"Column 'Day shift made' in Table 'Print machine' contains a duplicate value '0' and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table."

 

This is my table:

 

How can i change so it's allowed to have duplicates? In my data there will be duplicated numbers.

  • I changed a lot of the relationsships, so i only looked at the date. There was also some weird going on, it has been made some relationsships which shouldnt exist.

    Cleaned it all up and did the relationsships all over - Did the job

3 Replies

  • MAwwad's avatar
    MAwwad
    Solution Sage

     

    To allow duplicate values in the 'Day shift made' column, you can remove the relationship with the table where it is used as the primary key. However, this may affect the accuracy of your data, so you should consider whether it is necessary to maintain the relationship.

    If you still want to maintain the relationship and allow duplicate values, you can create a new column in the 'Print machine' table that generates unique values for each row, such as a row number or a GUID. You can then use this column as the primary key instead of the 'Day shift made' column.

    To create a row number column, you can use the following DAX formula:

     

     
    RowNumber = RANKX(ALL('Print machine'), [Day shift made])
     

    This formula ranks the rows in the 'Print machine' table based on the 'Day shift made' column, and generates a unique number for each row.

    Alternatively, to create a GUID column, you can use the following DAX formula:

     

     
    GUID = GUID()
     

    This formula generates a unique GUID value for each row in the table.

    After you have created the new column, you can use it as the primary key for the table and maintain the relationship with other tables without encountering the duplicate value error.

    • RVBIBS's avatar
      RVBIBS
      Regular Visitor

      The thing i don't understand, is that my date should be my primary key?

      How can i see the primary key, and change it for the dates?

      • RVBIBS's avatar
        RVBIBS
        Regular Visitor

        I changed a lot of the relationsships, so i only looked at the date. There was also some weird going on, it has been made some relationsships which shouldnt exist.

        Cleaned it all up and did the relationsships all over - Did the job