Forum Discussion
Collecting variable data from cells
- 4 years ago
Ah. You wrote to calculate length. But you really want length and width.
Try this (explanation later if needed)
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{ {"INDEX3D", Int64.Type}, {"length", Int64.Type}, {"edge1", type text}, {"edge2", type text}, {"width", Int64.Type}, {"edge3", type text}, {"edge4", type text}, {"Type", type text}, {"Q.", Int64.Type}}), #"Length x Quantity" = Table.AddColumn(#"Changed Type", "Length x Quantity", each [length] * [#"Q."], Int64.Type), #"Width x Quantity" = Table.AddColumn(#"Length x Quantity","Width x Quantity", each [width] * [#"Q."], Int64.Type), #"Filtered Rows" = Table.SelectRows(#"Width x Quantity", each ([Type] = "edge")), #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"length", "width", "Q.", "INDEX3D", "Type"}), #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"Length x Quantity", "Width x Quantity"}, "Attribute", "Value"), #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Lengths", each if [Attribute]="edge1" or [Attribute]="edge2" then [Length x Quantity] else [Width x Quantity]), #"Removed Columns1" = Table.RemoveColumns(#"Added Custom",{"Length x Quantity", "Width x Quantity", "Attribute"}), #"Grouped Rows" = Table.Group(#"Removed Columns1", {"Value"}, {{"Total Length", each List.Sum([Lengths]), type number}}) in #"Grouped Rows"
I will try again 🙂
Link to file is here: https://1drv.ms/x/s!AoS5q2ShsQhBgmMPGH8S6Jk-yiGl?e=dHD3gZ
Table inside with data and on another sheet sample how I like to get this Edge data.
RaudMees
The link does not work. Use something like OneDrive, DropBox or similar to share your file.
Or post your sample data as text and your expected results (from that data) as a screenshot here.
- RaudMees4 years agoRegular Visitor
Edited. Now it works I hope.
- ronrsnfld4 years ago
Super User
The link works, but I'm not understanding how you are deriving your Results from the data you are presenting.
For example, a method that will properly sum White will not work for the other types
- RaudMees4 years agoRegular Visitor
This is manually created sample from data to result. I need to automate this function somehow.