Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

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 t...
  • ImkeF's avatar
    ImkeF
    8 years ago

    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