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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

0

Issue : Duplicate primary key value detected by error because values are trimmed by Power BI Desktop

[EDIT] - I found the root cause of the issue : it seems that Power BI Desktop is trimming values and will consider (for instance) :  'AAA  ' = 'AAA' -- which triggers such discrepant behavior where it considers a well-designed Primary Key field as holding duplicates. Power Query is not making this mistake : 

Back End DB (Snowflake) : 2 entries with one having a space in the end

Thomas_Leillet_0-1668437168694.png

 

Power Query : 2 distinct rows, normal...

Thomas_Leillet_3-1668437681699.png

 

Power BI Desktop, even with this filtering applied : 

Thomas_Leillet_4-1668437764898.png

 

Deleting the relation already put in place, the data imported from a source of 2 rows end up in a table of 1 row : 

Thomas_Leillet_0-1668438147588.png

 

 

 

-----

[ORIGINAL POST]

 

 

 

 

Power Bi Desktop detects a duplicate key while refreshing datamodel whereas there is no such duplicate in my dataset - power query itelself does not detect such anomaly (see snapshots attached). The issue did not occur when modeling in Direct Query mode, but appeared when attempting to switch ot either Import or Dual mode.

 

Refresh : it says "duplicate Key with value " INC."

Thomas_Leillet_0-1668422680624.png

 

Full dataset profiling : no duplicates

Thomas_Leillet_2-1668422705117.png

 

Column filtering : one single value.

Thomas_Leillet_1-1668422695978.png

 

 

Status: Delivered
Comments
Anonymous
Not applicable

Hi @Thomas_Leillet 

As we all know that DAX does not recoginze space and capitalization . When your values are "AAA" and "AAA ", you always get "AAA" in Desktop view .

As for the "The issue did not occur when modeling in Direct Query mode, but appeared when attempting to switch ot either Import or Dual mode." you mentioned , my understanding is when you import your data from data source , Power Query will perform a transformation on the data , it is normally in Power Query Editor , but back to Desktop view , it will say "duplicate Key with value " INC." . 

 

Best Regards,
Community Support Team _ Ailsa Tao

Thomas_Leillet
Regular Visitor

OK - well it's obvious that not everybody knows all about PBI, and specifically this trailing spaces trimming default feature (which could be troublesome in some justified situations), but at least your answer brought me the piece of info that I used to lack. Thanks !