cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PBIX123 Frequent Visitor
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
Community Support Team
Community Support Team

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

Hi @PBIX123,

 

You can refer to below formula to achieve your requirementSmiley Sadunpivot 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 Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |
1 REPLY 1
Community Support Team
Community Support Team

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

Hi @PBIX123,

 

You can refer to below formula to achieve your requirementSmiley Sadunpivot 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 Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.



For learning resources/Release notes, please visit: | |