Forum Discussion

juan jimenez's avatar
juan jimenez
Iron Contributor
Apr 23, 2020
Solved

power query remove empty columns

hi,

Can anyone tell me if it is possible to "remove empty columns" as it is to "remove empty rows"?

Thanks Juan

  • juan jimenez 

    If automatically that could be function like

    (Source as table) as table =>
    
    let
        RemoveEmptyColumns = Table.SelectColumns(
            Source,
            List.Select(
                Table.ColumnNames(Source),
                each List.NonNullCount(Table.Column(Source,_)) <> 0
            )
        )
    in
        RemoveEmptyColumns

2 Replies

  • DhaniCole's avatar
    DhaniCole
    Brass Contributor

    juan jimenez 

    Depending on your table size, you could transpose the table in PQ, then filter out blank rows on a column, then transpose back.

     

    To keep the column headers though, you should demote the headers before you transpose, then promote them after you transpose the table back.

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    juan jimenez 

    If automatically that could be function like

    (Source as table) as table =>
    
    let
        RemoveEmptyColumns = Table.SelectColumns(
            Source,
            List.Select(
                Table.ColumnNames(Source),
                each List.NonNullCount(Table.Column(Source,_)) <> 0
            )
        )
    in
        RemoveEmptyColumns

Resources