Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sabeensp
Helper IV
Helper IV

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?

 

Yr.png

 

1 ACCEPTED SOLUTION

@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.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

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



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2kYes, column name will always be the same. Yr1, Yr2, and so on

@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.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

I would have approached it the same way @parry2k , with Table.ColumnNames and List.Zip.  A small change to reduce the number of steps would be to use this formula to make the list of Years for the column names with this:

 

=List.Transform({-1..3}, each Number.ToText(currentYear + _))

 

Regards,

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat agreed, assuming column numbers are in the same order and that's the reason I decided to not go with that path but thanks for pointing it out.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

selpaqm
Helper V
Helper V

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.

@selpaqmHow would that work next year when year will change next year?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors