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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
PBIX123
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
v-shex-msft
Community Support
Community Support

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
v-shex-msft
Community Support
Community Support

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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors