Forum

Rename Column Names...
 
Notifications
Clear all

Rename Column Names Dynamically

12 Posts
2 Users
0 Reactions
173 Views
(@back2awake)
Posts: 30
Eminent Member
Topic starter
 

Dear All,

I am getting that data from a folder. Every month I will receive the latest file and I have applied few transformations and the output is in a table. 

What I want is to change the month's name dynamically. Currently, the month's name appears in the below way.

"Apr-23" "May-23" and when I get June data, it will be "Jun-23" and so on.

What I want is to change these month's name dynamically upon refresh to the below:

"M1A" "M2A" and when I get June data, it should rename automatically to "M3A" and so on.

I have attached the picture for your reference.

I would really appreciate your help.1.PNG 

 
Posted : 13/07/2023 12:40 pm
Riny van Eekelen
(@riny)
Posts: 1196
Member Moderator
 

Perhaps the attached file helps you on your way. If not, please come back here.

 
Posted : 14/07/2023 2:44 am
(@back2awake)
Posts: 30
Eminent Member
Topic starter
 

Hi Riny,

Thank you very much for providing the solution. It is working for me. Now related to this I need one more favour.

Basically, I want to have 12 columns (M1A til M12A) in the power query. e.g.: please see the attached picture.

When I will receive the latest month's file, PQ will get the data for the folder and give the output as highlighted in green in the attachment but I want to also have blank columns in PQ for those months where I have not received the data. The way I highlighted in yellow in the attachment.

For example, June data I have not received it yet so there are blank columns for M3A until M12A. but when the data is received it should populate the M3A blank column with the data for June and keep (M4A til M12A) blank columns. It should do exactly the same for M4 onwards.

Also when there is no data it should have 12 blank columns only.

Your help would be appreciated.

2.PNG

 
Posted : 15/07/2023 7:51 pm
Riny van Eekelen
(@riny)
Posts: 1196
Member Moderator
 

You asked the same (or at least a very similar) question before and you mentioned that you had resolved the problem "in another way". What has changed?

 
Posted : 16/07/2023 1:23 am
(@back2awake)
Posts: 30
Eminent Member
Topic starter
 

Hi Riny,

Previously I manually added a row with these headings (M1A, M2A...so on) A2:L2. Via PQ I was loading the table under these headings in A3:B3 (due to having only two months of data). The problem was I now have two rows of headings, one at A2:L2 (added manually) and another at A3:B3 (added via PQ). That is causing a problem when I want to do another analysis through this data source. Yesterday when I changed the name from "Apr-23" to "M1A" (Thanks to you). I thought if blank columns can be created via PQ and data is loaded into relevant columns that would be a much better strategy and I would not have two different rows of headings.

I would appreciate if you could help.  

 
Posted : 16/07/2023 6:12 am
Riny van Eekelen
(@riny)
Posts: 1196
Member Moderator
 

OK but can you share a file? I find it hard to visualize what exactly you are doing.

 
Posted : 16/07/2023 7:21 am
(@back2awake)
Posts: 30
Eminent Member
Topic starter
 

Thank you Riny.

Please see the attached sample file. The first tab is the actual data file, which I will be receiving on a monthly basis. The second tab is the output I want via PQ as a table.

Your help would be appreciated.

 
Posted : 16/07/2023 7:54 am
Riny van Eekelen
(@riny)
Posts: 1196
Member Moderator
 

Thanks for the file but I can't refresh the queries. Table1 seem not to be what PQ wants and Table2 does not exist.

Perhaps you can recreate a file where all data tables and queries are included in the file?

 
Posted : 16/07/2023 8:08 am
(@back2awake)
Posts: 30
Eminent Member
Topic starter
 

Hi Riny,

Please see the attahced update file.

 
Posted : 16/07/2023 8:39 am
Riny van Eekelen
(@riny)
Posts: 1196
Member Moderator
 

See attached. Would that work for you?

 
Posted : 17/07/2023 12:36 am
(@back2awake)
Posts: 30
Eminent Member
Topic starter
 

Thank you so much, Riny. It is working now.

I really appreciate the time and effort you have put into resolving my queries.

 
Posted : 17/07/2023 7:55 am
Riny van Eekelen
(@riny)
Posts: 1196
Member Moderator
 

Glad I could help!

 
Posted : 17/07/2023 9:22 am
Share: