Forum Discussion
sabeensp
6 years agoHelper 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 simpl...
- 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.
mahoneypat
6 years agoMicrosoft Employee
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
parry2k
6 years agoSuper User
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.