Forum Discussion

ViorelCa's avatar
ViorelCa
Icon for Helper I rankHelper I
8 years ago
Solved

Power Query - Extract an Existing Column Name and put it in a new Custom Column

Dear Colleagues,

 

I did not find a solution for a simple problem:

 

Create a new custom column whose only content should be the name of an existing column in that Table.

 

Many thanks!

Viorel

  • Anonymous's avatar
    Anonymous
    8 years ago

    OK in that case your custom column's formula should be

    = List.First(Table.ColumnNames(#"Insert Previous Step Here"))

    ...for whatever the previous step was. I'm going to guess it's #"Renamed Columns" or #"Changed Type" or something like that.

15 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Which column name? Short of you typing in the name of the column, how is the query supposed to determine which column's name to use?

    • ViorelCa's avatar
      ViorelCa
      Icon for Helper I rankHelper I

      Sorry, let's say we have Column A, ColumnB and Column C.

       

      I want to make a new conditional column (D) that is filled with this text: "Column A"

       

      Many thanks!

      Viorel

      • ViorelCa's avatar
        ViorelCa
        Icon for Helper I rankHelper I

        Is there a function that extracts the name, something like Comun. Name ("Column A")?

  • radoslaw85's avatar
    radoslaw85
    Regular Visitor

    Hi there,
    im looking for something similiar,
    I will be creating multilanguage solution in power query, so im looking for API's

    For API's I got what I need, but im strugling to get Current Column Name.

    Imagine 4 columns: pl, it, es, fr.
     Now I would need a "simple" function that would retrive column name of the column it resides in. i.e
    if my formula resides in column name pl, it would retrive its name which is pl
    if my formula resides in column name es, it would retrive its name which is es

    Can some1 help?