Forum Discussion

marcus_giddings's avatar
marcus_giddings
Frequent Visitor
4 years ago

visuals stop working with dynamic column names

hi all , i have a dashboard that uses weekly sales data from a sql server the table i have looks somthing like this.

 

date_lwsales_lwdate_2wsales_2wdate_3wsales_3wdate_4wsales_4wdate_5wsales_5w
01/01/2022    1000      08/01/2022    2500       15/01/2022    1250         22/01/2022     4000          29/01/2022    3000       

 

my manager whants a table to show this data i a very specific way (replicating a legacy reportt that directors dont want to change), the layout he wants is to have the week number as the colmun header for the weeks sales data something like this.

 

01/01/2022    08/01/2022     15/01/2022    22/01/2022    29/01/2022     
10002500125040003000

 

i have been able to get this format in the data by using power query to change the column names, the data refreshes with out issue and the column names do change when the data in the underlying sql server data changes.

 

The issue that i have is that when the power bi data refreshes any visual that i have that uses one of the columns with a changed names stops working, this leads to an error for example with the column (25/12/2021), this column would no long exsist because the sql server data only contains 5 weeks of rolling data so that every week the dates in each column changes.

 

The only way around this is that every week i will need to manualy  remove the errored column from the visual and add in the column again but no with the updated name and then republish it back. im looking for a way that when the column names update the changes are reflected in the visuals with out manual intervention.

6 Replies

  • unfortunalty this method does not work for due to the data in my sql server not being structured like this and that the desired table does have more columns that only partain to the sales_lw so using the matrix column method would mean these extra columns being duplicated

  • Hi marcus_giddings ,

    You can fix this by importing the data with column Number as the column names and then promote the Dates as headers.

     

    This way I think you will not have this issue

     

    Regards,

  • i have looked at you solution but lookingfat you data structure, it does not match the structure in my sql server as this is like this

    date_lwsales_lwdate_2wsales_2wchange in salesnumebr of satff that made salesnumber of people that made purchases
    01/01/2022100008/01/2022250015001050

     

    so even if i could use you method the extra columns "change in sales, numebr of satff that made sales and number of people that made purchases" would end up being duplicated for each date which would look like this

     

    01/01/2022    08/01/2022   
    saleschange in salesnumebr of satff that made salesnumber of people that made purchasessaleschange in salesnumebr of satff that made salesnumber of people that made purchases
    100015001050250015001050

     

     but what i need is like this

     

    01/01/202208/01/2022change in salesnumebr of satff that made salesnumber of people that made purchases
    1000250015001050
  • somthing i have tried is when changing the column names via power query is instead of referencing the column that i want to change by what is name it content i have tried by referencing the column position in the table by using quueries simalr to this 

     

    = Table.RenameColumns(#"Changed Type",{{Table.ColumnNames(#"Changed Type"){3}, dbo_QLIK_WEEKLY_HOURS_no_append[Date_lw]{0}}})

     

    this also doesnt work

    • Thejeswar's avatar
      Thejeswar
      Super User

      Hi,

      I am not sure if trying to access the column names like this is possible, instead you can try to import it with column No in to Power BI