# Tags
**Software** : [[02 - Tags/Software/Power Query]]
**Functions** used : [[Table.Transpose]] [[Table.FillDown]] [[Table.ColumnNames]] [[Table.CombineColumns]] [[Text.Combine]] [[Table.FromColumns]] [[Table.ToColumns]] [[Table.UnpivotOtherColumns]] [[Table.SplitColumn]] [[Table.TransformColumnTypes]] [[Table.Pivot]] [[Excel.CurrentWorkbook]]
**Date** : 17-March-2025
# Description
- In This Video i show you how to deal with the Double Barrel Header problem you'll encounter in your day to day life. You'll get to use some m query functions to unpivot the dreaded double barrel header and clean your data easily.
# Video Link
<iframe width="560" height="315" src="https://www.youtube.com/embed/iMeuit1IiE4?si=3ZOg4AxY3ispzgUW" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
[GITHUB File Link](https://github.com/jbotes/powerbiTutorials/blob/main/PQ_DoubleBarrel_Video.xlsx)
# M-Query
```mquery
let
Source = Excel.CurrentWorkbook(){[Name="Table7"]}[Content],
DoubleBarrelHeader = Table.Transpose(Table.FirstN(Source,2)),
Filldown = Table.FillDown(DoubleBarrelHeader, Table.ColumnNames(DoubleBarrelHeader)),
CombinedHeader = Table.CombineColumns(Filldown,
Table.ColumnNames(Filldown),
each Text.Combine(_, "|"), "MergedColumn")[MergedColumn],
TableWithHeader = Table.FromColumns(Table.ToColumns(Table.Skip(Source,2)), CombinedHeader),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(TableWithHeader, {"Stock Code"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"PortfolioName", "Context"}),
#"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"PortfolioName", type text}, {"Context", type text}, {"Value", type number}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Context]), "Context", "Value", List.Sum)
in
#"Pivoted Column"
```
## Optional Tags
**Tags** :
**Technique** : [[Double Barrel Headers]] [[Dynamic Column Names]]