Forum Discussion

philongxpct's avatar
philongxpct
Frequent Visitor
9 years ago
Solved

Combine different columns from excels files!

             I have a nested tables (3 Columns: Name - Excel file's name; Combined - What columns to keep; D - workbook table). Ends users will type what columns to keep (mess columns per file :<) that my case. So, I want to select these columns dynamicly way.

             I try to play around with my data via this approach: https://bondarenkoivan.wordpress.com/2016/01/25/rename-columns-of-nested-tables-in-power-query/ but hard to rename columns cos so many dulicate columns.

             Now i trying to transforms "Table" columns before expand it base on same next rows content "Combine": = Table.TransformColumns(Custom1, {{"D", each Table.SelectColumns("D",[Combined],[Combine])}})

            So, yeah that error i face off. Anyone can help pls.

P/s: Sorry cos my english :<<.

  • MarcelBeug's avatar
    MarcelBeug
    9 years ago

    My suggestion would be to add a Custom Column with formula:

     

    = Table.SelectColumns([D],Text.Split([Combined],","))

    Next you can remove column D.

     

2 Replies

  • philongxpct's avatar
    philongxpct
    Frequent Visitor

    Update:

                    Just play around with https://bondarenkoivan.wordpress.com/2016/12/12/transform-column-using-custom-function-in-power-query-part-2/

                    My code here:

    Custom2 = Table.FromRecords(Table.TransformRows(Custom1),
                          (ref)=> Record.TransformFields(ref,
                                        {"D", each Table.SelectColumns(ref[D],ref[Combine],ref[Combine])}))

                    And new error:

    Expression.Error: 1 arguments were passed to a function which expects 2.
    Details:
    Pattern=
    Arguments=List

     

                    Still play around, any help is appricicated. Thanks

     

     

    Happy querying guys ^^!

    • MarcelBeug's avatar
      MarcelBeug
      Community Champion

      My suggestion would be to add a Custom Column with formula:

       

      = Table.SelectColumns([D],Text.Split([Combined],","))

      Next you can remove column D.