top of page

Excel Arena

This is the place, where we can test the boundaries of Excel functions.

Techniques to Remove Empty Columns in Excel and Power Query

Imagine our source data includes empty columns with headers, then we can utilize these 2 techniques.

ree

Method-1:


let

 Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],

 Result = Table.RemoveColumns(Source, List.Select(Table.ColumnNames(Source), (f) => List.Count(List.RemoveNulls(Table.Column(Source,f))) = 0 ))

in

 Result


Method-2:


let

 Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],

 Result = Table.RemoveColumns( Source, Table.SelectRows(Table.AddColumn(Table.Profile(Source), "Check", (f) => f[Count] - f[NullCount]), (x) => x[Check] = 0)[Column])

in

 Result


When there are empty columns without headers, Table feature in Excel will replace blank headers with column numbers. In such instances, we can apply the technique outlined below.


Method-3:


let

 Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],

 Result = Table.SelectColumns( Source, List.Select(Table.ColumnNames(Source), (f) => not Text.Contains(f,"Column")))

in

 Result


Method-4:

=FILTER(Data,BYCOL(Data<>"",OR))


Method-5:

=FILTER(Data,BYCOL(Data,LAMBDA(x,COUNTA(x)>1)))

Recent Posts

See All

Comments


  • LinkedIn
  • Facebook
  • Twitter
  • Instagram
bottom of page