let fnMergeRowsToHeader=(
pSTR_Source as text,
pINT_NbrRows as number
) =>
let
STR_Source=pSTR_Source,
Source = if STR_Source is table then STR_Source else Excel.CurrentWorkbook(){[Name=STR_Source]}[Content],
INT_NbrRows=pINT_NbrRows,
STR_BLANK=" ",
LST_SourceColumnsNames=Table.ColumnNames( Source),
TBL_FirstN=Table.FirstN(Source,INT_NbrRows),
TBL_TableToColumns=Table.ToColumns(TBL_FirstN),
LST_ColumnsHeaders = List.Transform(TBL_TableToColumns, (x)=> Text.Combine(x,STR_BLANK)),
TBL_Skip=Table.Skip( Source, INT_NbrRows ),
TBL_Final = Table.RenameColumns(TBL_Skip, List.Zip({LST_SourceColumnsNames, LST_ColumnsHeaders }))
in
TBL_Final
in
fnMergeRowsToHeader