Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Column in table has duplicate value error prevents applying the query

I am getting the following error after grouping and filling down missing data in step "Custom1", then expanding the data in step "Custom2".

The error is:

Column 'PMS-ID' in Table 'Fill Missing Dev' contains a duplicate value '724' 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.

1.PNG

 

 

 

 

 

 

 

 

My query is:

 

 

 

 

let
    Source = hPMS_HP,
    #"Merged Queries" = Table.NestedJoin(Source, {"PMS-ID"}, fConsolidatedPDA, {"Projekt-Id"}, "fConsolidatedPDA", JoinKind.LeftOuter),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Queries",{"Prio", "I / V / P", "Projekttyp"}),
    #"Expanded fConsolidatedPDA" = Table.ExpandTableColumn(#"Removed Columns", "fConsolidatedPDA", {"Exportdatum", "Projektkosten (Geplant) (MFr)", "Projektkosten (Ist) (MFr)", "Projektkosten (Verfügt) (MFr)"}, {"Exportdatum", "Projektkosten (Geplant) (MFr)", "Projektkosten (Ist) (MFr)", "Projektkosten (Verfügt) (MFr)"}),
    #"Sorted Rows1" = Table.Sort(#"Expanded fConsolidatedPDA",{{"PMS-ID", Order.Ascending}, {"Exportdatum", Order.Ascending}}),
    #"Replaced Value1" = Table.ReplaceValue(#"Sorted Rows1",0,null,Replacer.ReplaceValue,{"Projektkosten (Geplant) (MFr)", "Projektkosten (Ist) (MFr)", "Projektkosten (Verfügt) (MFr)"}),
    Custom1 = Table.Group( #"Replaced Value1", {"PMS-ID"}, {{"Rows",each Table.ReverseRows(Table.FillDown(Table.ReverseRows(Table.FillDown(_, {"Projektkosten (Geplant) (MFr)", "Projektkosten (Ist) (MFr)", "Projektkosten (Verfügt) (MFr)"})), {"Projektkosten (Geplant) (MFr)", "Projektkosten (Ist) (MFr)", "Projektkosten (Verfügt) (MFr)"} )) , type table [#"Projektname"=text, #"PMS-ID"=number, #"Projektkosten (Geplant) (MFr)"=number, #"Projektkosten (Ist) (MFr)"=number, #"Projektkosten (Verfügt) (MFr)"=number]}}),
    Custom2 = Table.ExpandTableColumn( Custom1, "Rows", {"ID","Exportdatum", "Projektkosten (Geplant) (MFr)", "Projektkosten (Ist) (MFr)", "Projektkosten (Verfügt) (MFr)"}, {"ID","Exportdatum", "Projektkosten (Geplant) (MFr)", "Projektkosten (Ist) (MFr)", "Projektkosten (Verfügt) (MFr)"} )
in
    Custom2

 

 

 

 

In other topics, I read the solution is to change the cardinality to one-to-many, but I don't have any relationships. (at least, ones that I can find). 

 

 

Data (before transformation):

3.PNG

Data (after transformation): 

2.PNG

It is correct that PMS-ID has duplicate values in the data and it should not be a primary key. The value "724" is not the only duplicate and neither the first in my data. I have not been able to apply my changes to the query due to this error message.

 

How can I fix this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I solved the problem by applying the following steps:

  1. Create an index column from "Add Column" tab.
  2. Duplicated "PMS-ID" with new name "PMD-ID Copy"
  3. Deleted "PMS-ID2
  4. Renamed "PMS-ID Copy" to "PMS-ID"

It seems that Power Query applys a primary key to the "PMS-ID" column when expanding. By following those steps, Power Query will be forced to look for another primary key candidate, which is the newly created Index. 

 

The above statement is my interpretation and is not based on any documented information. Therefore, use it with caution.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

I solved the problem by applying the following steps:

  1. Create an index column from "Add Column" tab.
  2. Duplicated "PMS-ID" with new name "PMD-ID Copy"
  3. Deleted "PMS-ID2
  4. Renamed "PMS-ID Copy" to "PMS-ID"

It seems that Power Query applys a primary key to the "PMS-ID" column when expanding. By following those steps, Power Query will be forced to look for another primary key candidate, which is the newly created Index. 

 

The above statement is my interpretation and is not based on any documented information. Therefore, use it with caution.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors