Duplicates in SharePoint Datasheet view / Export to Spreadsheet (Excel)

Recently I encountered a bug in SharePoint where sometimes duplicate items appear when viewing items in Datasheet view in SharePoint.  This also happens when using the Export to Spreadsheet (Excel).  If duplicates appear in Datasheet view, they will also appear during Export to Spreadsheet and vice versa.

This happens only under specific circumstances.  The base list must have a required lookup column/field that is multi-value.  The view must not include this column.

A required, multi-value lookup column is created to demonstrate the problem:1-required-multi-value-lookup-field

An example of the list data in standard view, showing the “Region” column:
2-example-data-showing-required-multi-value-lookup-field

I created a new view without the “Region” column to show the duplicates bug.  Standard view appears normal:
3-view-without-required-multi-value-lookup-field

Same view, but when switched to Datasheet view, duplicate records show:
4-datasheet-view-without-required-multi-value-lookup-field-shows-duplicate-items

Same view in Export to Spreadsheet shows duplicates:
5-export-to-spreadsheet-without-required-multi-value-lookup-field-shows-duplicate-items

If the column is not required, everything works fine.  If the column exists in the view, everything is fine.  It is only when the required column is omitted from the view that you see duplicates.

If the column is included from the view, everything is normal during Edit in Datasheet mode:
6-datasheet-view-shows-multi-value-lookup-field-no-duplicate-items

Duplicates are now gone in Export to Spreadsheet as well:
7-export-to-spreadsheet-with-required-multi-value-lookup-field-no-duplicates

There seems to be no fix for this problem.  The work-around is, if you have a required multi-value lookup column, to always add the column to views, especially datasheet views.  If a user creates their own view without the column, they may run into this problem.  User education is the only solution in this case.

Although this seems like a rare circumstance, it does appear that multiple SharePoint users are encountering this problem.  This affects both WSS 3.0 and MOSS 2007.

12 Responsesto “Duplicates in SharePoint Datasheet view / Export to Spreadsheet (Excel)”

  1. Brettski says:

    Thanks! Great explanation of this puzzling issue I just encountered, I feel like you saved me hours of troubleshooting. I owe you a beer.

  2. MCDONAMW says:

    AAAAHHH Thanks! This was driving me nuts! Unfortunately I think my problem is not so easily resolved.

    I have required fields that are lookup fields. When these fields are added to the datasheet view, I can’t edit any of the items due to some invalid text injected into the view for this particular column!

    Irritated.

  3. MCDONAMW says:

    Turns out my statement isn’t fully true. It seems this issue only occurs with certain types of lookup fields. When I drop them down they list each item as #string#blahblah.. this is what’s throwing it off. I think it’s due to this particular look up field linking to a calculated field.

  4. Andrew says:

    Yep, very helpful, thanks very much. If Brettski is buying the first beer, I’ll get the next round.

  5. Eric says:

    I’ll second Brettski. I encountered this problem while using a column of one list as a lookup column in a second. If this first list had other required columns that allowed multiple values, the column value being looked up would appear once for every value in the multiple values columns.

    Thanks for putting me on the right track! Making the multiple value columns not required in the first list got around this problem.

  6. Todd says:

    I’ll add 1 comment here.

    I was having the same problem and had NO current lookup fields and NO allowed multiple value fields.

    Turns out that at 1 time I did, had made entries, and then changed the nature of that field to something else.

    Once I showed that field in the view of interest, problem went away.

  7. Todd says:

    Correction.

    It was my “Assigned To” field. I have a required, allow multiple people, Assigned To field which, when left out of the view, does create multiple lines in both data sheet view and when exporting.

    I was looking for a true LOOKUP field as stated previously on this page.

  8. Tesfaye says:

    I have got the same issue. When the Multilookup field is not included in a list view and when we use SPList.GetItems(SPQuery), this returns a duplicate Item which differs by the value of MultipleLookup values. Ex. If Item 1 has multiple lookup value of a,b then it comes twice with multipleLookup value of a and b with the same ID.
    So this issue is only fixed by users till Microsoft decided to do something.

  9. Kevin says:

    Thanks a lot. It saved me lots of time.

  10. PopeyeTheSailor says:

    Thank GOD!

    I was the same as Todd… the Assigned To field was doing me in. (And this problem was doing my head in!)

    I’ll do a round of shots after everyone else has got the beers in.

    Cheers,
    Popeye.

  11. RomaPete says:

    Now, does anyone know of a way to suppress the index numbers, e.g., in the example above “Midwest;#4;….” I believe that #4 means that “Midwest” is item 4 in its original list. My users are complaining about them….
    Thanks!

  12. RM says:

    It also shows up in SP2010

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>