Forum Discussion
How to append multiple columns from inside one table
- 6 years ago
Hi apoje
I am not sure why you've completely ignored my solution all along 🤔. It does exactly what you showed in your first post in a simple way. If the base table is "tbl_bundle" in the files you've shared, you can create a blank query with the following M code and you'll get the result. It is the same as I posted a couple of days ago already:
let Source = tbl_bundle, #"Removed Columns" = Table.RemoveColumns(Source,{"SKU-bundleID"}), ExtractColumns_ = Table.ToColumns(#"Removed Columns"), ContentCols_ = List.Combine(List.Alternate(ExtractColumns_,1,1,1)), QuantityCols_ = List.Combine(List.Alternate(ExtractColumns_,1,1,0)), final_ = Table.FromColumns({ContentCols_, QuantityCols_}, {"ContentAll", "QuantityAll"}) in final_Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Ok good. The error doesn't look that is coming from that code. It says it's trying to convert multiplication.1 to number and it can't do it. Check your previous o next steps and check if you have a convert to number somewhere. You might have wrong data in the column that is not allowing you to convert it or apply math over the column.
You can always check my code by parts. Starting without the combine to see if it works:
Table.RenameColumns(
Table.SelectColumns(tblSL, "var-nr-1", "Multiplication.1")
,{{"var-nr-1", "var-nr"},{"Multiplication.1", "Quantity"} })
If you want you can share previous steps so we can help you find the error.
Regards,
Hi ibarrau
I have checked once again and I do not see any overlaps in the data type.
here is the link of my workbook:
I appreciate your help!
Regards,
Andraz
Andraz
- ibarrau6 years agoSuper User
Is the error from a specific step? or is it showing that when close & apply?
The sharepoint link doesn't show me anything. Just an excel with A1 = ExternealData_1.
Can you show the "advanced editor" power query code? that way we can check whats is in the query besides what I have sent you.
Regards,
- apoje6 years agoHelper II
Hi ibarrau I have shared the flie where all the data is only loaded with "connection only". So there are no tables loaded. Maybe if you go under Queries&Connections you'll se it...
The blank query only has your code nothing else and that results in the error message I have sent you.
The code of the connected table is:
let Source = Excel.Workbook(File.Contents("C:\...\fba-pošiljanje-goods-in-v01.xlsx"), null, true), tblSLO_FBA_Table = Source{[Item="tblSLO_FBA",Kind="Table"]}[Data], #"Changed Type" = Table.TransformColumnTypes(tblSLO_FBA_Table,{{"Date", type date}, {"Invoice number", type text}, {"SKU", type text}, {" Shipment ID", type any}, {"desc", type text}, {"qty ordered", Int64.Type}, {"Put on invoice (x - for YES, DONE - for DONE)", type text}}), #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([#"Put on invoice (x - for YES, DONE - for DONE)"] = "x")), #"Grouped Rows" = Table.Group(#"Filtered Rows", {"SKU"}, {{"Quantity", each List.Sum([qty ordered]), type number}}), #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"SKU"}, tbl_bundle, {"SKU-amz"}, "tbl_bundle", JoinKind.LeftOuter), #"Expanded tbl_bundle" = Table.ExpandTableColumn(#"Merged Queries", "tbl_bundle", {"var-nr-1", "content-1", "var-nr-2", "content-2", "var-nr-3", "content-3", "var-nr-4", "content-4"}, {"var-nr-1", "content-1", "var-nr-2", "content-2", "var-nr-3", "content-3", "var-nr-4", "content-4"}), #"Changed Type1" = Table.TransformColumnTypes(#"Expanded tbl_bundle",{{"content-1", Int64.Type}, {"Quantity", Int64.Type}, {"content-2", Int64.Type}, {"content-3", Int64.Type}, {"content-4", Int64.Type}}), #"Inserted Multiplication" = Table.AddColumn(#"Changed Type1", "Multiplication", each List.Product({[Quantity], [#"content-1"]}), Int64.Type), #"Inserted Multiplication1" = Table.AddColumn(#"Inserted Multiplication", "Multiplication.1", each List.Product({[Quantity], [#"content-2"]}), Int64.Type), #"Inserted Multiplication2" = Table.AddColumn(#"Inserted Multiplication1", "Multiplication.2", each List.Product({[Quantity], [#"content-3"]}), Int64.Type), #"Inserted Multiplication3" = Table.AddColumn(#"Inserted Multiplication2", "Multiplication.3", each List.Product({[Quantity], [#"content-4"]}), Int64.Type), #"Reordered Columns" = Table.ReorderColumns(#"Inserted Multiplication3",{"SKU", "Quantity", "var-nr-1", "content-1", "Multiplication", "var-nr-2", "content-2", "Multiplication.1", "var-nr-3", "content-3", "Multiplication.2", "var-nr-4", "content-4", "Multiplication.3"}), #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Multiplication.3", "Multiplication.4"}, {"Multiplication.2", "Multiplication.3"}, {"Multiplication.1", "Multiplication.2"}, {"Multiplication", "Multiplication.1"}}) in #"Renamed Columns"There is one more querry connected where I am doing the outer join from:
let Source = Excel.Workbook(File.Contents("C:\...\dAMZ-BundleContent-v02.xlsx"), null, true), tbl_bundle_Table = Source{[Item="tbl_bundle",Kind="Table"]}[Data], #"Changed Type" = Table.TransformColumnTypes(tbl_bundle_Table,{{"SKU-amz", type text}, {"ASIN", type text}, {"title-amz", type text}, {"var-nr-1", type text}, {"content-1", Int64.Type}, {"var-nr-2", type text}, {"content-2", Int64.Type}, {"var-nr-3", type text}, {"content-3", Int64.Type}, {"var-nr-4", type text}, {"content-4", Int64.Type}, {"Fulfillment-Channel", type text}}), #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"ASIN", "Fulfillment-Channel"}), #"Replaced Value" = Table.ReplaceValue(#"Removed Columns",null,0,Replacer.ReplaceValue,{"var-nr-1", "content-1", "var-nr-2", "content-2", "var-nr-3", "content-3", "var-nr-4", "content-4"}), #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value",{{"var-nr-2", type text}, {"var-nr-1", type text}, {"var-nr-3", type text}, {"var-nr-4", type text}, {"content-1", Int64.Type}, {"content-2", Int64.Type}, {"content-3", Int64.Type}, {"content-4", Int64.Type}}) in #"Changed Type1"that is all that is connected to.
Andraz
- ibarrau6 years agoSuper User
Ok. At the end of your table, try adding a new step changing the type of the columns as you want. Convert all Multiplication.N to number so the new table have the correct data. This code:
#"Inserted Multiplication1" = Table.AddColumn(#"Inserted Multiplication", "Multiplication.1", each List.Product({[Quantity], [#"content-2"]}), Int64.Type),This is not changing the column to Int64.Type it is just leting the engine know that you want to have a number but it won't convert it. The real step changing types will show error if you have character that is not a number. You can validate that "Keeping Errors" as the last step of the table. If the step doesn't show rows then delete the step and your dataset is ready to be appended.
Regards,