Forum Discussion

ksicard2430's avatar
ksicard2430
Helper I
5 years ago

Refresh Preview - Unexpected Error: An item with the same key has already been added

Hello Power BI community,

 

I could use some help in trouble shooting the source of an error I am receiving. I am developing a large reporting system in Power BI and today I decided to refresh the Preview's for all of my queries. It's unknown to me why I am receiving the below error as all of these queries were working without issue previously. 

 

Almost all of my queries are receiving this error. After googling the error it seems that there may be duplicate keys. This does not make sense to me as all of these queries were working previously without issue and no changes have been made to the data sources.

 

1. I am running the most current version of Power BI Desktop

2. The data sources are tables and views within my SQL Database

3. I am able to refresh the report in Power BI Service via a data gateway without issue

 

If I do have duplicate keys like the error is mentioning, what exactly is this referring to? I am able to open the saved PBiX file and change the columns in power query prior to hitting refresh preview if this will allow for a fix. I also have control over the SQL environment if changes need to be made within the data source.

 

Any information to get me going in the right direction would be most appreciated!

 

4 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    If you open the advanced editor and copy the M code, and paste it into a new blank query, does that query get the error too?  I wonder if something behind the scenes of the existing tables got corrupted somehow.

    Regards,

    Pat

    • ksicard2430's avatar
      ksicard2430
      Helper I

      Pat,

       

      After conducting the test you just mentioned it is indeed returing the error in a blank query.

       

       

      After pasting the M code into a blank query the query populated fine until I clicked refresh preview.

       

      Are you able to provide some additional information into what this means and what route I will have to go to correct this?

       

      mahoneypat 

    • ksicard2430's avatar
      ksicard2430
      Helper I

      After some additional testing I am noticing the below.

       

      Within the Power Query Editor if I disable Load to Report in the properties menu for each query and then re-enable the setting allows me to successfully refresh my queries without issue. However, all of my measures and calculated columns will have to be re-built. This is an extensive amount of work, but you may be correct in that something on the back end of the power query was corrupted with this PBI report.

       

      Does anybody have any ideas on how to get around this issue without a full re-build of my measures and calculated columns?

       

      • mahoneypat's avatar
        mahoneypat
        Microsoft Employee

        I don't have more to offer on the issue; haven't seen it but glad you found a workaround.  If you can open the pbix, you can create a separate measures table and move your measures there, and at least copy your column expressions out.

         

        Regards,

        Pat