Forum Discussion
Remove text in one specific cell in Power Query Editor
- 3 years ago
Hi Anonymous ,
thanks, that explanation would have made an excellent initial thread 😉To rename the first column dynamically, you can use this formula:
Table.RenameColumns( #"Promoted Headers", {Table.ColumnNames(#"Promoted Headers"){0}, "Week"})So instead of hardcoding the column name, you grab its value by fetching the tables column names as list and and then grab the first element from the list {0} - with 0 as a positional index because the M-language is zero based.
Hey, thanks for reaching out ImkeF
The logic is basically that I would want to find the first column and simply rename it to "Week".
When using the renaming function it is not dynamic as it simply looks for the column called "202252" and renames it to "Week". Please see attached screenshot.
In reality I will upload data with other dates such as 202245 etc and then it would not work... Can I somehow replace "202252" in the code above with first column number or so?
Thanks
/Sammy
Hi Anonymous ,
thanks, that explanation would have made an excellent initial thread 😉
To rename the first column dynamically, you can use this formula:
Table.RenameColumns( #"Promoted Headers", {Table.ColumnNames(#"Promoted Headers"){0}, "Week"})
So instead of hardcoding the column name, you grab its value by fetching the tables column names as list and and then grab the first element from the list {0} - with 0 as a positional index because the M-language is zero based.