Forum Discussion

sabeensp's avatar
sabeensp
Helper IV
6 years ago
Solved

Dynamic Column Name

Hello,

I have a table as shown below. I have to plot the data in Grid, but column needs to be actual year. Every Year, Year will increment such as current Year + 1, + 2, and so on. So I cannot simply change the Colum Header. Table Field Names will not change in the Database. Is there a way in M-Query to change teh column nae such as YEAR(Now()), YEAR(Now()) +1 and so on. Please advice how to accomplish this?

 

 

  • parry2k's avatar
    parry2k
    6 years ago

    sabeensp see attached, look at table called Table in power query and it take the current year as a base and then replaces column names accordingly. It can be improved further but I think it is a good start.

     

     

7 Replies

  • Hi,

     

    did you try to change it from Transform Data section.

    On home section click Transform data, then choose related table from queries section. change the table column headers with double click on it or just right click and rename it. this will be added to Applied steps section and even you refresh the data it will replace them by itself.

  • selpaqm does the column name always like yr1 yr2 yr3...if yes then I can get you the solution which will be dynamic

      • parry2k's avatar
        parry2k
        Super User

        sabeensp see attached, look at table called Table in power query and it take the current year as a base and then replaces column names accordingly. It can be improved further but I think it is a good start.