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. 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,
Sorry ibarrau I'm too stupid to understand 😕
the below code is already in the editor:
#"Inserted Multiplication" = Table.AddColumn(#"Changed Type1", "Multiplication", each List.Product({[Quantity], [#"content-1"]}), Int64.Type)
so what exactly do I need to change?
Thanks!
Andraz
- AlB6 years agoCommunity Champion
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
- ibarrau6 years agoSuper User
Please don't think that, you might be starting and I may not always make myself clear 🙂
I'm talking about this:
https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-data-types
A change of data looks like this:
= Table.TransformColumnTypes(#"Last Step",{{"Column1", Int64.Type}})Then about errors you can check this:
https://youtu.be/drrh6ciVvXY?t=99
Try that on multiplication.1 column so we can check what is this about.
Regards,
- apoje6 years agoHelper II
Hey ibarrau,
thanks for all your help I really appreciate it.
I think I understand what you meant - but looking at the table from where the error should originate - there is none.
I have no idea where to go from here. I even manually checked the data (because there is not many rows) - I still do not find it.
Can I send you the workbook somewhere if you can check it out?
Regards,
Andraz - ibarrau6 years agoSuper User
Ok, if the data is not private then send me that and I'll check it.
Regards
- apoje6 years agoHelper II
HI ibarrau I created a folder on OneDrive and amended the data.
The file where is the code is: invoice-v01
the folder link: https://ipotechnik-my.sharepoint.com/:f:/g/personal/andraz_poje_ipotechnik_de/EueJyvbjKrFFt5RzW5wvobIBlhSu0GyODYP14vXo_INRMw?e=Ai8ZE6
Thank you for the help!
Andraz
- LiziM4 years agoFrequent Visitor
SOLVED:
https://community.powerbi.com/t5/Desktop/Appending-columns/m-p/1555845#M635475
Hi AIB,
I have a similar problem, which I've tried to apply your solutions to, but I'm having some issues still.
Currently, I have a table like this:
Job Card ID Artisan 1 Artisan 2 Artisan 3 1 Bradley James 2 Mike Bradley John
I would like to create a table like this (excluding blanks as shown below):
Job Card ID Artisan 1 Bradley 1 James 2 Mike 2 Bradley 2 John So far, I am able to get all the artisans into one column, but I am unsure on how to get the corresponding Job Card ID.
Any help would be much appreciated and I'll be sure to let you know if the solution does/doesn't work!
SOLVED:
https://community.powerbi.com/t5/Desktop/Appending-columns/m-p/1555845#M635475