PDA

View Full Version : Table.Addcolumn



MikeManwaring
2016-04-20, 10:31 AM
Hi All
I hope someone can point me in the right direction.
I am effectively trying to create an addcolumn list and contents of those column from a second list but it does not work.
Is there any resources i can read to achieve this result?
many thanks
Mike

Ken Puls
2016-04-20, 05:34 PM
Hi Mike,

Do you have a small sample you can upload, and can you include a table with the format you want at the end? (Only needs to be 6-10 rows, but would make it a lot easier to figure out what you are trying to accomplish.)

Thanks!

MikeManwaring
2016-04-21, 09:11 AM
Hi Ken
thank you for the response.
I don't have a particular table but i will explain further.

If i have a query of say 5 columns and i know that the output needs a static 25 columns of data, even if some of these columns are blank.
what i was trying to do was create a list which consisted of the column names.

myNewColumns
A
B
C
D
etc

myNewColumnContents
null
null
test
156
etc

and based on the formula

Table.AddColumn(table as table, newColumnName as text, columnGenerator as function, optional columnType as nullable type)

I tried Table.AddColumn(#"previous step", myNewColumns, each myNewColumnContents) which gave an error.

Any ideas or have you already done this?

Regards
Mike

Pecoflyer
2016-04-21, 09:43 AM
Hi

I think Ken meant you to upload a sample file ( showing what you have and expected results)

Have a look at this (http://www.excelguru.ca/forums/faq.php?faq=vb3_reading_posting#faq_vb3_attachments) to see how it works

MikeManwaring
2016-04-21, 10:09 AM
Here is an example as requested
Thanks

Mike



4846

Bill Szysz
2016-04-21, 11:25 AM
Hi Mike,
Try this solution below

Regards

MikeManwaring
2016-04-21, 11:37 AM
Thank you Bill, that works great.

Ken Puls
2016-04-21, 05:55 PM
Beat me to it, Bill. I was thinking something along the same lines there. :)