Forum Discussion

GeekAlfPro's avatar
GeekAlfPro
Helper V
5 years ago
Solved

File name startwith as parameter

Hello,   i built a few queries with power query and i want to pass the filenames as parameters. often, the files start with the same string and end with dates or numbers.   i managed to have the...
  • smpa01's avatar
    5 years ago
    	let
        fx=(p as text)=> let
        Source = Folder.Files(Dossier_Données),
        #"Colonne conditionnelle ajoutée" = Table.AddColumn(Source, "NomFichier", each if 
    Text.StartsWith([Name], p) then [Name] 
    else null),
        #"Colonnes permutées" = Table.ReorderColumns(#"Colonne conditionnelle ajoutée",{"Content", "Name", "Extension", "NomFichier", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}),
        #"Lignes filtrées" = Table.SelectRows(#"Colonnes permutées", each ([NomFichier] <> null)),
        #"Colonnes supprimées" = Table.RemoveColumns(#"Lignes filtrées",{"Content", "Name", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}),
        NomFichier = #"Colonnes supprimées"{0}[NomFichier]
    in
        NomFichier
        in 
        fx