The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Each Year will get a new File with the New Year-Month as a header Row.
How to Unpivot the data.
Sample Data :
Key | Jan-23 | Feb-23 | Mar-23 | Apr-23 |
AA1 | 454 | 46 | 67 | 778 |
AA2 | 54 | 123 | 7545 | 57 |
AA3 | 6564 | 56 | 656 | 656 |
AA4 | 34 | 245 | 657 | 55 |
AA5 | 2342 | 34 | 23 | 54 |
AA6 | 56 | 12 | 354 | 454 |
AA7 | 787 | 5464 | 123 | 123 |
AA8 | 234 | 57 | 56 | 679 |
Key | Jan-24 | Feb-24 | Mar-24 | Apr-24 |
AA1 | 54 | 43 | 545 | 778 |
AA2 | 545 | 6 | 3423 | 3 |
AA3 | 65 | 56 | 656 | 656 |
AA4 | 34 | 7 | 23 | 7776 |
AA5 | 2342 | 56 | 34 | 54 |
AA6 | 6 | 7 | 354 | 454 |
AA7 | 787 | 4545 | 434 | 43 |
AA8 | 234 | 57 | 56 | 34 |
=Table.UnpiovtOtherColumns(PreviousStepName,{"Key"},"MonthYear","Value")
Thanks @wdx223_Daniel / for the Response.
The Above I have already tried but, But I feel this doesn't work when another file comes in into same dataset. for another Year.
If you see below i have exported 2 year of Data, but even if i will make first row as header , In the Header Row will have year 2023, But same will get unpivoted. Even Year 2024 Data will get unpivoted with 2023 only.
That's where i am facing the issue. in the same dataset every year , i have add the files, But Header Row has to be changed every year.
=Table.Combine(Table.Group(PreviousStepName,"Column1",{"n",each Table.RenameColumns(Table.UnpivotOtherColumns(Table.PromoteHeaders(_),List.FirstN(Record.ToList(_{0}),2),"Date","Value"),{Record.ToList(_{0}){0},Table.ColumnNames(_){0}})})[n])
It looks like you are combining files from multiple years. You will want to apply the unpivot recommended by @wdx223_Daniel to your sample transformation query. You can then hop back into your main query after the files are combined and repivot or transform however you need.