Excel file with multiple row of column headers, want to make it one column header using azure data factory

Tulsi K 20 Reputation points
2024-02-21T05:29:13.7466667+00:00

Hi, I have an Excel file used as a data source in Data Factory, where I encountered a challenge with multiple rows for column headers (Nested headers). Specifically, I aim to consolidate two rows into a single row to streamline the header columns. To provide a clearer understanding, consider the following example: User's image

By merging these rows, I aim to make like this.

project1 test1

project1 test2

project1 test3

project2 test4

project2 test5

project2 test6

Guidance on how to efficiently accomplish this task within Data Factory would be helpful.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
Microsoft 365 and Office | Excel | For business | Windows
{count} votes

2 answers

Sort by: Most helpful
  1. AnnuKumari-MSFT 34,566 Reputation points Microsoft Employee Moderator
    2024-02-28T09:28:00.75+00:00

    Hi Khimlal, Tulsi ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your query here.

    As per my understanding you are trying to merge rows having header in excel into single header . However , it is not just one step process , we need to perform data transformation on the source dataset. Additionally, in your scenario , test1,test2, and test3 needs to be converted to project1 test1, project1 test2, project1 test3 and the next set of columns : test4,test5 and test6 to be converted to project2 test4, project2 test5 and project2test .

    • Add Source transformation and point the dataset to the source excel file. Remove 'First row as header'
    • Add Filter transformation and provide this expression: !startsWith({_col0_},'Project')
    • Add derived column transformation and add column pattern to replace test1 with project1 test1 and so on with other
      User's image
    • Add sink transformation and in dataset select 'first row as header'

    Hope it helps. Kindly accept the answer by clicking on Accept answer button. Thankyou


  2. Ashish Mathur 100.8K Reputation points Volunteer Moderator
    2025-08-02T05:30:22.6233333+00:00

    Hi,

    This M code in Power Query works

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        SplitTable = Table.SplitAt(Source,2),
        Headings = List.Transform(Table.ToColumns(Table.FromRows(List.Transform(Table.ToRows(SplitTable{0}), each Table.FillDown(Table.FromColumns({_},{"Value"}),{"Value"})[Value]))), each Text.Combine(_,"/")),
        Custom1 = Table.FromColumns(Table.ToColumns(SplitTable{1}),Headings),
        #"Added Index" = Table.AddIndexColumn(Custom1, "Index", 1, 1, Int64.Type),
        #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Index"}, "Attribute", "Value"),
        #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Project", "Test"}),
        #"Removed Columns" = Table.RemoveColumns(#"Split Column by Delimiter",{"Index"})
    in
        #"Removed Columns"
    

    Hope this helps.

    User's image

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.