1
votes

I have a requirement where the name of the column in the report changes dynamically and I am trying to rename it in the advanced editor in PowerBI.

Renamed Columns" = Table.RenameColumns(#"Added Conditional Column1",{{"AgingReport_201801022101.txt", "Report Name"}, {"1/3/2018 2:38:13 AM", "Report Created Time"}})

Here, AgingReport_201801022101.txt could change to AgingReport_12321321321.txton next refresh and similarly this 1/3/2018 2:38:13 AM is subjectible to change as well on further refresh.

Because this changes, my calculated column in PowerBI doesn't recognize the column names on further refreshes.

1

1 Answers

2
votes

You forgot to mention some required information, but assuming you have 1 column starting with "AgingReport" and assuming you have 1 column with a name that would convert to a date/time value and assuming that can be done with your current culture, then you can use the following code:

#"Renamed Columns" = Table.TransformColumnNames(#"Added Conditional Column1", each if Text.StartsWith(_,"AgingReport") then "Report Name" else if Value.FromText(_) is datetime then "Report Created Time" else _)