Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a table and a drop down list which uses a power query connection.
My current set up allows the user to select an option from the drop down list and the some of the table columns will change to reflect that choice:
For example, user selects Aqueduct from the dropdown list, they get a table full of consistent columns that don't change, but the last 5 columns labelled Header 1 to 5 become Aqueduct Type, Aqueduct Design and then a later step removes any remaining columns with "Header" in.
E.G:
#"Renamed Columns1" = if (FilterAssetClass = "Aqueduct") then Table.RenameColumns(#"Renamed Columns",{{"Header1","Aqueduct Type"},{"Header2","Aqueduct Design"}})
else if (FilterAssetClass = "Basin") then Table.RenameColumns(#"Renamed Columns",{{"Header1","Listing Grade"}})
else if (FilterAssetClass = "Bridge") then Table.RenameColumns(#"Renamed Columns",{{"Header1","Bridge Type"},{"Header2","Bridge Abut Material"},{"Header3","Bridge Deck Material"}})
....
RemoveColumns = let columnsToRemove = List.Select(Table.ColumnNames(#"Replaced Value"), each Text.Contains(_,"Header")) in Table.RemoveColumns(#"Replaced Value",columnsToRemove),
I have ~18 options within the dropdown list for the user to choose from, and I've got it working via many else if statements (similar to the above), I'm assuming there must be a better way of doing it but can't figure out how.
Any help would be greatly appreciated!
Hi @Anonymous ,
You can try to convert them to list to rename the columns' name.
Please refer these articles which introduce it in details:
In addition, you can try to create a custom function to rename them:
Using M to dynamically change column names in PowerQuery
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks Yingjie Li,
I've tried it via number 1, and got a list of lists with an additional column for the FilterAssetClass choice in this example. But I'm not able to figure out how to make it conditional on the user choice.
If I wanted to convert from the 5 column names to 5 other names only it would work, but I want to convert 5 columns names to 5 other names based on what the user has sellected and it's that condition that I'm stuck on if you have any advice?
Essentially I want it to take in the dropdown list selection, and check that selection through a table and then when it matches replace old columns to new columns (specific to that dropdown list). Which I think neither of the links helps with.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.