Power Query - Eliminate blank cells in each column (generate lists for nonblank data)

procha

New Member
Joined
Jan 19, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

I searched a lot but didn't find an answer to this.

I have loaded in power query 4 columns like this (after some tweaking)

REP 1REP 2REP 3REP 4
nullCustomer1nullnull
Customer2
null
nullnull
Customer3nullnullnull
nullnullCustomer4null
nullnullnullCustomer5

I'd like to have a list like this:

REP 1REP 2REP 3REP4
Customer2Customer1Customer4Customer5
Customer3nullnullnull

Any help appreciated.

Thank you
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    lst = Table.ToColumns(Source),
    lst1 = List.Transform(lst, each List.RemoveNulls(_)),
    Result = Table.FromColumns(lst1, Table.ColumnNames(Source))
in
    Result

Book1
ABCDEFGHIJ
1REP 1REP 2REP 3REP 4REP 1REP 2REP 3REP 4
2Customer1Customer2Customer1Customer4Customer5
3Customer2Customer3
4Customer3
5Customer4
6Customer5
7
Sheet3
 
Upvote 0
Nice technique @JGordon11.

I went a roundabout way of doing it. Always forget about Table.ToColumns.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table7"]}[Content],
    Transpose = Table.Transpose(Source),
    TR = Table.TransformRows(Transpose,(row)=> List.RemoveNulls(Record.ToList(row))),
    ToTable = Table.FromList(TR, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Extract = Table.TransformColumns(ToTable, {"Column1", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    Split = Table.SplitColumn(Extract, "Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    Transpose1 = Table.Transpose(Split)
in
    Transpose1
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    lst = Table.ToColumns(Source),
    lst1 = List.Transform(lst, each List.RemoveNulls(_)),
    Result = Table.FromColumns(lst1, Table.ColumnNames(Source))
in
    Result
Beautiful, thank you so much!

I could never get there using the predefined actions.
 
Upvote 0
Nice technique @JGordon11.

I went a roundabout way of doing it. Always forget about Table.ToColumns.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table7"]}[Content],
    Transpose = Table.Transpose(Source),
    TR = Table.TransformRows(Transpose,(row)=> List.RemoveNulls(Record.ToList(row))),
    ToTable = Table.FromList(TR, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Extract = Table.TransformColumns(ToTable, {"Column1", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    Split = Table.SplitColumn(Extract, "Column1", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    Transpose1 = Table.Transpose(Split)
in
    Transpose1
Thank you also, but I did JGordon11 way :)
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,513
Members
449,168
Latest member
CheerfulWalker

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