Hey I need help with my code, I am trying to figure out how to deal with different files having different number of pages.
I am actually using power bi to extract data from a folder of pdf's but the deal is that those files have different number of pages, in the code below you can see that I have 3 tables, each of them is on a page(Table1 for the table of the first page..), so for pdf files having only one page the tables 2 and 3 do not exist, so I am looking for a way to ignore parts of code where there will be errors
let
Source = Pdf.Tables(#"Paramètre de l'exemple de fichier1"),
Table1 = Source{[Id="Table1"]}[Data],
#"En-têtes promus1" = Table.PromoteHeaders(Table1, [PromoteAllScalars=true]),
Table2=Source{[Id="Table2"]}[Data],
#"En-têtes promus2" = Table.PromoteHeaders(Table2, [PromoteAllScalars=true]),
Table3=Source{[Id="Table3"]}[Data],
#"En-têtes promus3" = Table.PromoteHeaders(Table3, [PromoteAllScalars=true]),
#"Table" = Table.Combine({#"En-têtes promus1", #"En-têtes promus2",#"En-têtes promus3"}),
#"Index ajouté" = Table.AddIndexColumn(Table, "Index", 1, 1),
#"Colonnes renommées" = Table.RenameColumns(#"Index ajouté",{{"Index", "Page"}})
in
#"Colonnes renommées"