Forum Discussion

bellspartan23's avatar
bellspartan23
Frequent Visitor
2 years ago

Weekly Changes to Column Headers (Date Field)

Hello,

 

I'm still trying to get more comfortable in Power Query but hoping there is an easy solution for what I'm trying to do. I'm currently working with a few files where the formatting is a bit different. The fields that include the "date" are displayed as column headers and the products are displayed as rows (image below).

 

In order to clean this up, I unpivoted the date headers so the dates would be displayed alongside the products in the rows. This has been working great so far. The challenge is that each time the file is pulled it's only limited to a certain # of historical weeks, which means column headers will keep getting removed and new headers will be added (consistently 104 weeks of data).

 

Is there a simple way to manage this in Power Query so that I won't get errors week over week? I can send screenshots. I'm not sure how others have handled this so any assistance would be great! Thanks!

 

4 Replies

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    find the step that using the hard code of column names

    replace those hard code names to Table.ColumnNames(PreviousStepName)

  • Select non-dated columns, click "unpivot other columns" in the transform tab. 

  • bellspartan23's avatar
    bellspartan23
    Frequent Visitor

    Thank you! I definitely overlooked that. Figured there was a simple solution. Appreciate the quick help here!