Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
I have imported an excel file into power bi and using power query to clean my data. The image below shows that my first column has dates. This column contains the latest date in my data, 31/12/2023, in the first row as well as the last row. I want to replace the first row value of the latest date with the text 'Date' and then will promote the first row to headers so my column has heading Date.
I want to make this step dynamic as every month this excel file is updated, it will contain the latest date in the first row as well as the last row.
Could anyone help with this?
Thanks in advance
Solved! Go to Solution.
Good day kishanr,
If it is always the first row you want to promote to headers an approach is:
After using the GUI to promote the first row (and assuming this step is called "Promoted Headers"), the code to rename the column would be (assuming the date is in the first column i.e. the column of index 0).
#"Rename Column" = Table.RenameColumns( #"Promoted Headers", {{Table.ColumnNames(#"Promoted Headers"){0},"Date"}} )
Hope this helps.
Good day kishanr,
If it is always the first row you want to promote to headers an approach is:
After using the GUI to promote the first row (and assuming this step is called "Promoted Headers"), the code to rename the column would be (assuming the date is in the first column i.e. the column of index 0).
#"Rename Column" = Table.RenameColumns( #"Promoted Headers", {{Table.ColumnNames(#"Promoted Headers"){0},"Date"}} )
Hope this helps.
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
69 | |
61 | |
18 | |
16 | |
13 |