Forum Discussion

bhill024's avatar
bhill024
Regular Visitor
10 years ago
Solved

dates as column names

I am pulling in data from a SQL server database  that is stored vertically (one row per quarter) and pivoting it so I have the  dates as columns. After pivoting, it looks like this:   [ID]  [Variab...
  • KGrice's avatar
    10 years ago

    Hi bhill024. I can't pull from SQL Server right now to confirm, but I don't think the column names will change at all. This is the case if I create a table in Excel, import it, and then go back to the Excel file and change a column header. The table in Power BI retains the original column name.

     

    The good news is your calculations won't break, but of course your column headings will be misleading. Is there a requirement to dynamically name the columns? If not, a simple workaround would be to alias the columns as something like CurrentPeriod, CurrentPeriod-1, CurrentPeriod-2, CurrentPeriod-3. If you want to make it more obvious what the corresponding dates are in your report, you could pull the dynamic headings into a separate table as row values, and display them on the report.

  • v-haibl-msft's avatar
    10 years ago

    bhill024

     

    The columns name should be able to change after you change the quarter in your data source. Then if your calculations reference these columns by name, they will not work anymore.

    Based on my testing, the column position will also change after we click Refresh in Power BI Desktop as below. So the workaround provide by KGrice should be a good choice.

     

    Best Regards,

    Herbert