Forum Discussion
damit230183
1 year agoHelper II
Error while doing PIVOT in power query
Hi, I have table like below generated from PDF file, when i tried to pivot based on Field name and Value with Don't Aggregate, there is an error "There were too many elements in the enumer...
- 1 year ago
Hi damit230183 ,
Try the following steps:
- Group by Field Name
- Add a custom Column wiht index
- Expand the new column
- Delete the previous group by column
- Pivot by Field Name and don't aggregate the Value
- Delete index column
See the full code below:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQrKz0kFUsGlSVmpySVKsToQ4eCSxBKQeEhqRWIxWNQIu2IjJMV+qeUKkflF2TjUKxhi6HDLyS/KTElUio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"File Name" = _t, #"Field Name" = _t, Value = _t]), #"Grouped Rows" = Table.Group(Source, {"Field Name"}, {{"Count", each _, type table [File Name=nullable text, Field Name=nullable text, Value=nullable text]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn ([Count], "Index", 1)), #"Expanded Custom1" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"File Name", "Value", "Index"}, {"File Name", "Value", "Index"}), #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom1",{"Count"}), #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[#"Field Name"]), "Field Name", "Value") in #"Pivoted Column"Believe this is what you need please let me know if there is the need for any further assistance
RemyO
1 year agoResolver I
Option 1) Dont import fieldname
Option 2) Delete fieldname from resultset after importing
OPtion 3) dont pivot over Fieldname but over eithe 1 of the other columns
- damit2301831 year agoHelper II
Field Name custome created field in power query after pulling 2 pdf files from Folder.
Field name is must becuase value under field name is COLUMN NAME we are going to use.
Thanks