Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Remove rows of certain columns with Query

Hi,


I have a table with several columns and what I want is to eliminate the first row of certain columns, NOT all of them.
I tried it in Query but it does in all the columns.

 

Is it possible to do what I want?

 

Thank you very much and best regards.

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

3 steps:

  1. Convert table to list of columns
  2. Transform all entries in the list (remove first nulls and blanks)
  3. Convert list of columns back to table:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lFSitWJVgLSxgZglhFIzMQAJmoKZMUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ColumnA = _t, ColumnB = _t]),
    TableToColumns = Table.ToColumns(Source),
    DeleteNulls = List.Transform(TableToColumns, each if List.First(_)=null or List.First(_) = "" then List.Skip(_,1) else _),
    Reassemble = Table.FromColumns(DeleteNulls, Table.ColumnNames(Source))
in
    Reassemble

Imke Feldmann

www.TheBIccountant.com -- How to integrate M-code into your solution  -- Check out more PBI- learning resources here

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
bizbi
Advocate I
Advocate I

Hello,

 

Can you please specify the problem is more detail - may be using an image of a sample table.

 

(Using excel terminology here) Would you like to remove the value of say cell B2, D2 and F2 and replace them by zero or shift the cells up? (assuming row 1 is all column headers)

Anonymous
Not applicable

Hello @bizbi,

 

I have the following table:

 

COLUMN ACOLUMN BCOLUMN CCOLUMN DCOLUMN E
100 6060 
 40  30

 

What I want is to eliminate the cells B2 and E2, moving the whole column B and E one row up, so that the table is as follows:

 

COLUMN ACOLUMN BCOLUMN CCOLUMN DCOLUMN E
10040606030
   
  

 

Thank you very much and best regards.

ImkeF
Community Champion
Community Champion

3 steps:

  1. Convert table to list of columns
  2. Transform all entries in the list (remove first nulls and blanks)
  3. Convert list of columns back to table:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lFSitWJVgLSxgZglhFIzMQAJmoKZMUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ColumnA = _t, ColumnB = _t]),
    TableToColumns = Table.ToColumns(Source),
    DeleteNulls = List.Transform(TableToColumns, each if List.First(_)=null or List.First(_) = "" then List.Skip(_,1) else _),
    Reassemble = Table.FromColumns(DeleteNulls, Table.ColumnNames(Source))
in
    Reassemble

Imke Feldmann

www.TheBIccountant.com -- How to integrate M-code into your solution  -- Check out more PBI- learning resources here

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

If you weren't wanting to retain the blank cell in columns A/C/D you could have transposed the table, merged the first two columns and then transposed it back again

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors