Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hello everyone, I'm loading data from a data folder. In it, there is one file per organizational unit, whose row structure (= key figures) is always identical. In the columns are the respective values of the area and the organisational sub-units . That means the rows are structured identically, the number of columns varies.
Example:
| Kennzahl | Definition | Bereich ABC | Abteilung HGF | Abteilung ONM |
| Kennzahl 1 | Beschreibung KnZ 1 | 4250 | 750 | 3500 |
| Kennzahl 2 | Beschreibung KnZ 2 | 475 | 300 | 175 |
| Kennzahl 3 | Beschreibung KnZ 3 | 41% | 5% | 41% |
| Kennzahl 4 | Beschreibung KnZ 4 | 1,2 | 0,4 | 0,8 |
<b>Datei 2</b>
| Kennzahl | Definition | Bereich GHI | Abteilung QRS | Abteilung UVW |
| Kennzahl 1 | Beschreibung KnZ 1 | 2500 | 500 | 2000 |
| Kennzahl 2 | Beschreibung KnZ 2 | 530 | 150 | 380 |
| Kennzahl 3 | Beschreibung KnZ 3 | 32% | 12% | 25% |
| Kennzahl 4 | Beschreibung KnZ 4 | 1,5 | 0,6 | 0,9 |
Taget:
| Kennzahl | Definition | Bereich ABC | Abteilung HGF | Abteilung ONM | Bereich GHI | Abteilung QRS | Abteilung UVW |
| Kennzahl 1 | Beschreibung KnZ 1 | 4250 | 750 | 3500 | 2500 | 500 | 2000 |
| Kennzahl 2 | Beschreibung KnZ 2 | 475 | 300 | 175 | 530 | 150 | 380 |
| Kennzahl 3 | Beschreibung KnZ 3 | 41% | 5% | 41% | 32% | 12% | 25% |
| Kennzahl 4 | Beschreibung KnZ 4 | 1,2 | 0,4 | 0,8 | 1,5 | 0,6 | 0,9 |
With the ordinary combining, the files are put below each other. I have already read a lot and tried various things, and found and tried variants with using index or pivot, but I have not come to my solution pattern. With the index, my data disappeared during index creation, and afterwards the instructions said "expand data again," but I couldn't manage that. Now I had an index for each metric "Definition", but the other columns were gone. With pivoting, I then had all the data duplicated in rows and columns. I just can't find a clear solution. And I really also need a step-by-step explanation or the complete M-Code to understand, because I need to solve this problem in multiple requirements.
Many thanks for your help and best regards,
Kiwi
In German:
Hallo zusammen,
ich habe folgendes Anliegen:
Ich rufe die Daten aus einem Ordner ab, Darin befinden sich je Organisationsbereich eine Dateien, deren Zeilenaufbau (= Kennzahlen) immer identisch ist. In den Spalten sind die jeweiligen Werte des Bereichs und der zum Bereich gehörenden Abteilungen. Das heißt die Zeilen sind identisch aufgebaut, die Anzahl der Spalten variiert.
Hier ein Muster:
<b>Datei 1</b>
Kennzahl Definition Bereich ABC Abteilung HGF Abteilung ONM
Kennzahl 1 Beschreibung KnZ 1 4250 750 3500
Kennzahl 2 Beschreibung KnZ 2 475 300 175
Kennzahl 3 Beschreibung KnZ 3 41% 5% 41%
Kennzahl 4 Beschreibung KnZ 4 1,2 0,4 0,8
<b>Datei 2</b>
Kennzahl Definition Bereich GHI Abteilung QRS Abteilung UVW
Kennzahl 1 Beschreibung KnZ 1 2500 500 2000
Kennzahl 2 Beschreibung KnZ 2 530 150 380
Kennzahl 3 Beschreibung KnZ 3 32% 12% 25%
Kennzahl 4 Beschreibung KnZ 4 1,5 0,6 0,9
Daraus möchte ich nun eine Gesamtdatei erstellen in der Form, dass die ersten beiden Spalten "Kennzahl" und "Definition" bestehen bleiben und die Spalten "Bereich..." und "Abteilung..." nebeneinandergestellt werden:
Ziel:
Kennzahl Definition Bereich ABC Abteilung HGF Abteilung ONM Bereich GHI Abteilung QRS Abteilung UVW
Kennzahl 1 Beschreibung KnZ 1 4250 750 3500 2500 500 2000
Kennzahl 2 Beschreibung KnZ 2 475 300 175 530 150 380
Kennzahl 3 Beschreibung KnZ 3 41% 5% 41% 32% 12% 25%
Kennzahl 4 Beschreibung KnZ 4 1,2 0,4 0,8 1,5 0,6 0,9
Beim "herkömmlichen" Kombinieren, werden die Dateien untereinandergehängt. Ich habe schon viel nachgelesen und probiert und Varianten mit Index und Spalte pivotieren gefunden und ausprobiert, aber bin nicht zu meinem Lösungsmuster gekommen. Bei Index verschwanden meine Daten bei der Indexbildung, danach hieß es in der Anleitung "Daten wieder expandieren" aber ich habe das nicht hinbekommen. Nun hatte ich zwar je Kennzahl einen Index aber die anderen Spalten waren weg. Beim Pivotieren habe ich anschließend alle Daten mehrfach in Zeilen und Spalten enthalten. Ich finde einfach keine saubere Lösung. Und ich brauche auch wirklich eine Schritt-für-Schritt-Erklärung oder die vollständige Darstellung der Umsetzung im Erweiterten Editor um es zu Verstehen, denn dieses Problem muss ich in mehreren Anforderungen lösen.
Vielen lieben Dank für eure Hilfe und Gruß,
KiWi
Solved! Go to Solution.
Hello @Kiwi_911 , in this case, it is important to understand that the Folder Combine function in Power Query works by default as an Append (stacking rows), while the requirement is to merge the data side by side.
The files need to be merged column-wise based on the common keys:
Kennzahl
Definition
This is not an Append scenario, but a Merge (Join) scenario across multiple files.
When using:
Home → Get Data → Folder → Combine
Power Query assumes that all files have the same structure and should be appended. However, in this situation:
The rows are identical across all files (Kennzahl)
The columns vary between files (Organisational Units)
The correct approach is to append the files temporarily and then pivot the organisational columns in order to convert the rows back into columns.
Try this:
let
Source = Folder.Files("C:\YourFolderPath"),
FilteredFiles = Table.SelectRows(Source, each [Extension] = ".xlsx"),
GetData = Table.AddColumn(FilteredFiles, "Data", each Excel.Workbook([Content], true)),
ExpandSheets = Table.ExpandTableColumn(GetData, "Data", {"Data"}),
ExpandData = Table.ExpandTableColumn(ExpandSheets, "Data", {"Kennzahl","Definition","Column3","Column4","Column5"}),
Unpivoted = Table.UnpivotOtherColumns(ExpandData, {"Kennzahl","Definition"}, "Attribute", "Value"),
Pivoted = Table.Pivot(Unpivoted, List.Distinct(Unpivoted[Attribute]), "Attribute", "Value")
in
Pivoted
Official Microsoft documentation:
Unpivot columns - Power Query | Microsoft Learn
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn
Hi @Kiwi_911 ,
another option is to do two transpose operations, one for every single file and one for the final combined file, and wait with promoting the headers until the end of the process.
Assuming that you have a basic "Load from folder" setup,
you have to do the following:
Hope that helps. If you need more information or my demo file, please let me know...
Thanks so much for your help, Zanqueta. It works!
Hi @Kiwi_911 ,
another option is to do two transpose operations, one for every single file and one for the final combined file, and wait with promoting the headers until the end of the process.
Assuming that you have a basic "Load from folder" setup,
you have to do the following:
Hope that helps. If you need more information or my demo file, please let me know...
Hello Hans-Georg, thank you very much for your help. One correction, in line "Promoted Headers" I had to add a "," at the end. It works! Perfekt, thanks!
Hello @Kiwi_911 , in this case, it is important to understand that the Folder Combine function in Power Query works by default as an Append (stacking rows), while the requirement is to merge the data side by side.
The files need to be merged column-wise based on the common keys:
Kennzahl
Definition
This is not an Append scenario, but a Merge (Join) scenario across multiple files.
When using:
Home → Get Data → Folder → Combine
Power Query assumes that all files have the same structure and should be appended. However, in this situation:
The rows are identical across all files (Kennzahl)
The columns vary between files (Organisational Units)
The correct approach is to append the files temporarily and then pivot the organisational columns in order to convert the rows back into columns.
Try this:
let
Source = Folder.Files("C:\YourFolderPath"),
FilteredFiles = Table.SelectRows(Source, each [Extension] = ".xlsx"),
GetData = Table.AddColumn(FilteredFiles, "Data", each Excel.Workbook([Content], true)),
ExpandSheets = Table.ExpandTableColumn(GetData, "Data", {"Data"}),
ExpandData = Table.ExpandTableColumn(ExpandSheets, "Data", {"Kennzahl","Definition","Column3","Column4","Column5"}),
Unpivoted = Table.UnpivotOtherColumns(ExpandData, {"Kennzahl","Definition"}, "Attribute", "Value"),
Pivoted = Table.Pivot(Unpivoted, List.Distinct(Unpivoted[Attribute]), "Attribute", "Value")
in
Pivoted
Official Microsoft documentation:
Unpivot columns - Power Query | Microsoft Learn
If this response was helpful in any way, I’d gladly accept a kudo.
Please mark it as the correct solution. It helps other community members find their way faster.
Connect with me on LinkedIn
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 8 | |
| 6 | |
| 5 | |
| 5 | |
| 4 |