Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Error: Too many elements in the enumeration to complete the operation

I have downloaded a bunch of files (each one has one set of data of the power consumption of an electronic device) to Power BI. My goal is to graph the Power along time, so I only need the power values and the timestamp. When I try to pivot the column to get one column for power and one column for timestamp I get this error :

Too many elements in the enumeration to complete the operation
NameValue
power_mw0
timestamp2019-04-24T11:45:57.396440
power_mw0
timestamp2019-04-24T11:46:02.188844
power_mw0
timestamp2019-04-24T11:46:07.416614
power_mw0
timestamp2019-04-24T11:46:12.207765
power_mw0
timestamp2019-04-24T11:46:17.435759
power_mw0
timestamp2019-04-24T11:46:22.226059
power_mw0
timestamp2019-04-24T11:46:27.164159
power_mw7163
timestamp2019-04-24T11:46:32.252352
power_mw4922
timestamp2019-04-24T11:46:37.187028
power_mw4464
timestamp2019-04-24T11:46:42.371088
power_mw1747
timestamp2019-04-24T11:46:47.203619

 

The table is way bigger than this one, this is just an example. Can anyone please help? 

  • Something like this is what you want. Just replace the Source line with your data

    // Table1
    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ndG9CoNADMDxd7nZHvnOnc/RTaR0cOgglVbw9RvoVgftrSE//oQMQ1qe2/S6zVvqEqSxG9L6mKf3ep+XmBBgvYBcSK6IvWivnrmayHf1H2s9UMZSikiL9Sxohi0WKRO4m7bY6LK61gZL0SWDNusZTXBvHY2POUdaiZV+uVSiEzzqxYHKjovJMRfK7Ahlx9HFT3CPf7Fh3D5+AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Value", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Name"}, {{"Values", each _[Value], type table [Name=text, Value=text]}}),
        #"Transposed Table" = Table.Transpose(#"Grouped Rows"),
        #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
        #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"power_mw", type any}, {"timestamp", type any}}),
        Custom1 = List.Zip({#"Changed Type1"[power_mw]{0}, #"Changed Type1"[timestamp]{0}}),
        Custom2 = Table.FromRows(Custom1),
        #"Renamed Columns" = Table.RenameColumns(Custom2,{{"Column2", "timestamp"}, {"Column1", "power_mw"}})
    in
        #"Renamed Columns"

1 Reply

  • artemus's avatar
    artemus
    Microsoft Employee

    Something like this is what you want. Just replace the Source line with your data

    // Table1
    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ndG9CoNADMDxd7nZHvnOnc/RTaR0cOgglVbw9RvoVgftrSE//oQMQ1qe2/S6zVvqEqSxG9L6mKf3ep+XmBBgvYBcSK6IvWivnrmayHf1H2s9UMZSikiL9Sxohi0WKRO4m7bY6LK61gZL0SWDNusZTXBvHY2POUdaiZV+uVSiEzzqxYHKjovJMRfK7Ahlx9HFT3CPf7Fh3D5+AA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, Value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Value", type text}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Name"}, {{"Values", each _[Value], type table [Name=text, Value=text]}}),
        #"Transposed Table" = Table.Transpose(#"Grouped Rows"),
        #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
        #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"power_mw", type any}, {"timestamp", type any}}),
        Custom1 = List.Zip({#"Changed Type1"[power_mw]{0}, #"Changed Type1"[timestamp]{0}}),
        Custom2 = Table.FromRows(Custom1),
        #"Renamed Columns" = Table.RenameColumns(Custom2,{{"Column2", "timestamp"}, {"Column1", "power_mw"}})
    in
        #"Renamed Columns"