Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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!
Solved! Go to Solution.
Hi @PBIX123,
You can refer to below formula to achieve your requirement:(unpivot and pivot)
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
Hi @PBIX123,
You can refer to below formula to achieve your requirement:(unpivot and pivot)
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