Inserting blank rows between queries in the table.

Martin sherk

Board Regular
Joined
Sep 11, 2022
Messages
94
Office Version
  1. 365
  2. 2016
I have Appended 4 query tables together in 1 table and loaded them into my excel. however, is there a way I can insert blank rows in the table between each query and type something in 1 of that empty rows or maybe insert a header for each query in that table?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Create a table with only one blank row (and the same column names), and append it to the first two tables before the appends.
 
Upvote 0
Solution
Sure. Create a blank query and use this:
Power Query:
let
    Source = Table.ColumnNames(Table1),
    ConvertedToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    TransposedTable = Table.Transpose(ConvertedToTable),
    RenamedColumns = Table.RenameColumns(TransposedTable,{{"Column1", "Table1Col1Name"}, {"Column2", "Table1Col2Name"}})
in
    RenamedColumns
 
Upvote 0
Sure. Create a blank query and use this:
Power Query:
let
    Source = Table.ColumnNames(Table1),
    ConvertedToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    TransposedTable = Table.Transpose(ConvertedToTable),
    RenamedColumns = Table.RenameColumns(TransposedTable,{{"Column1", "Table1Col1Name"}, {"Column2", "Table1Col2Name"}})
in
    RenamedColumns
I am facing this error:
Expression.Error: We cannot convert a value of type Table to type List.
Details:
Value=

Type=[Type]


Power Query:
let
    Source = #"All tables Together",
    ConvertedToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    TransposedTable = Table.Transpose(ConvertedToTable),
    RenamedColumns = Table.RenameColumns(TransposedTable,{{"Column1", "Table1Col1Name"}, {"Column2", "Table1Col2Name"}})
in
    RenamedColumns
 
Upvote 0
I am facing this error:
Expression.Error: We cannot convert a value of type Table to type List.
Details:
Value=

Type=[Type]


Power Query:
let
    Source = #"All tables Together",
    ConvertedToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    TransposedTable = Table.Transpose(ConvertedToTable),
    RenamedColumns = Table.RenameColumns(TransposedTable,{{"Column1", "Table1Col1Name"}, {"Column2", "Table1Col2Name"}})
in
    RenamedColumns
Source is not a step, it's a Query Name. Everything I posted was done through the UI. I only took the spaces out of the step names to get rid of the #"" cluttrer.
 
Upvote 0
Perhaps looping through queries to be appended and insert a blank row at the beginning of each table with header text in the first column, and others null. Field names and field counts should be adapted in the code (field1, field2, etc.).
Something like this:

Power Query:
let

    // List of Queries already exist
    QueryTables = {Table1, Table2, Table3, Table4},

    TablesToBeAppended = List.Generate(
        () => [i = 0],
        each [i] < List.Count(QueryTables) ,
        each [i = [i] + 1],
        each Table.InsertRows(QueryTables{[i]}, 0, {
            [
                field1 = "Header " & Number.ToText([i] + 1),
                field2 = null,
                field3 = null
            ]
        })
    ),

    Source = Table.Combine(TablesToBeAppended)
in
    Source
 
Upvote 0
Perhaps looping through queries to be appended and insert a blank row at the beginning of each table with header text in the first column, and others null. Field names and field counts should be adapted in the code (field1, field2, etc.).
Something like this:

Power Query:
let

    // List of Queries already exist
    QueryTables = {Table1, Table2, Table3, Table4},

    TablesToBeAppended = List.Generate(
        () => [i = 0],
        each [i] < List.Count(QueryTables) ,
        each [i = [i] + 1],
        each Table.InsertRows(QueryTables{[i]}, 0, {
            [
                field1 = "Header " & Number.ToText([i] + 1),
                field2 = null,
                field3 = null
            ]
        })
    ),

    Source = Table.Combine(TablesToBeAppended)
in
    Source
Thank you sir for your time, sadly it's a bid advanced for me to use the M lang. .. i'll study your answer tho.
 
Upvote 0

Forum statistics

Threads
1,223,400
Messages
6,171,891
Members
452,431
Latest member
TiffanyMcllwain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top