cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Error: "There were too many elements in the enumeration" - urgent

Hi, I am currently working with Power Query to merge few tables from SQL Server. I have both ID and ITEMID from 2 different tables and columns containing timestamps from 2 different tables combined together as well. What I am trying to achieve is having data with unique combination of ID and ITEMID and flatten the timestamps. (Preview in image below). The issue is it suddenly creating duplicates after "Add Custom" and "Expanded Column" for certain timestamps columns. Thus, when I tried to load the data. I face the error message "There were too many elements in the enumeration". Help on this is greatly appreciated!

SAMPLE.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Error: "There were too many elements in the enumeration" - urgent

Hi @PBIX123,

 

You can refer to below formula to achieve your requirement:(unpivot and pivot)

4.PNG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXICYkN9Q30jA0MLBUsrQ1MrI0ugkFKsDkIeiIxgSgzNrYyBaozhCpyxG4DQYGhlZGJlYqYUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, ITEMID = _t, Start = _t, End = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"ITEMID", type text}, {"Start", type datetime}, {"End", type datetime}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID", "ITEMID"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

If above not help, can you please share some sample data for testing and coding formula? (store them in excel file, then update to onedrive or google drive and share link here)

 

Notice: do mask or remove sensitive data before sharing.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
Highlighted
Community Support
Community Support

Re: Error: "There were too many elements in the enumeration" - urgent

Hi @PBIX123,

 

You can refer to below formula to achieve your requirement:(unpivot and pivot)

4.PNG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXICYkN9Q30jA0MLBUsrQ1MrI0ugkFKsDkIeiIxgSgzNrYyBaozhCpyxG4DQYGhlZGJlYqYUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, ITEMID = _t, Start = _t, End = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"ITEMID", type text}, {"Start", type datetime}, {"End", type datetime}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID", "ITEMID"}, "Attribute", "Value"),
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

If above not help, can you please share some sample data for testing and coding formula? (store them in excel file, then update to onedrive or google drive and share link here)

 

Notice: do mask or remove sensitive data before sharing.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors