Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to delete all rows except the first one?

Hi,   The source is a folder which contains many pdf files. All of them have only one table with at least one row of headers and some rows of data. A few files just show the table with the headers ...
  • edhans's avatar
    4 years ago

    You can count the rows with Table.RowCount, so your formula would be something like

     

    ValidationStep = if Table.RowCount(PreviousStep) > 1 then {your filter here} else PreviousStep

     

     

    So this maybe:

    let
        Quelle = Pdf.Tables(Parameter1, [Implementation="1.3"]),
        Table001 = Quelle{[Id="Table001"]}[Data],
        #"headers" = Table.PromoteHeaders(Table001, [PromoteAllScalars=true]),
        #"number of rows" = Table.RowCount(#"headers"),
        #"single line" = (#"number of rows")-1,
        #"result" = if #"number of rows" > 1 then Table.RemoveRows(#"headers", 1, (#"single line")) else #"single line"
    in
        #"result"