PQ: Remove/Delete rows if specfic row of all columns are blank.

countryfan_nt

Well-known Member
Joined
May 19, 2004
Messages
765
Office Version
  1. 365
Platform
  1. Windows
Hello friends, Hope all is safe & well!
Please help me with Power Query. I want to delete the entire rows: 7, 11, 13, 14 and 15; based on the conditions that all cells are empty in all existing columns.

Thank you very much in advance!

Please
picture.jpg
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
you can try
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Index = Table.AddIndexColumn(Source, "Index", 1, 1),
    UOC = Table.UnpivotOtherColumns(Index, {"Index"}, "Attribute", "Value"),
    Pivot = Table.Pivot(UOC, List.Distinct(UOC[Attribute]), "Attribute", "Value"),
    RC = Table.RemoveColumns(Pivot,{"Index"})
in
    RC
with don;t aggregate option

btw. it will remove all full blank rows
 
Last edited:
Upvote 0
or this with columns sorted asc
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Index = Table.AddIndexColumn(Source, "Index", 1, 1),
    UOC = Table.Unpivot(Index, Table.ColumnNames(Source), "Attribute", "Value"),
    Sort = Table.Sort(UOC,{{"Attribute", Order.Ascending}}),
    Pivot = Table.Pivot(Sort, List.Distinct(Sort[Attribute]), "Attribute", "Value"),
    RC = Table.RemoveColumns(Pivot,{"Index"})
in
    RC
 
Upvote 0
or just use
= Table.SelectRows(Source, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
 
Upvote 0
Another option:
Rich (BB code):
= Table.RemoveMatchingRows(Source,{Record.FromList(List.Repeat({null},Table.ColumnCount(Source)),Table.ColumnNames(Source))})
 
Upvote 0
WOW! Thanks a lot! so all of the above will ONLY delete the rows 7, 11, 13, 14 and 15; the deleting of any should only happen if all the row is blank in all column.
 
Upvote 0
if there are only 7,11,13,14,15 are totally blank they will be removed
if there is more totally blank rows they will be removed also
 
Upvote 0
one more alternative
= Table.SelectRows(Source, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {not null})))
it will select all rows with data instead removing null rows
 
Upvote 0

Forum statistics

Threads
1,225,665
Messages
6,186,312
Members
453,349
Latest member
neam

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