Forum Discussion

dadb25's avatar
dadb25
Helper I
2 years ago
Solved

Sort files by month

Hi Community,   I use data in a Sharepoint folder, where 3 news files are automatically stored every days.   I want to sort them, to keep the 3 earliest files (sorted by column modified). ...
  • Einomi's avatar
    Einomi
    2 years ago

    Essaye cela dans ton code, 

    let
        Source = Ta Source SharePoint,
        AddYear = Table.AddColumn(Source, "Year", each Date.Year([Date modified]), type number),
        AddYearMonth = Table.AddColumn(AddYear, "Month", each Date.Month([Date modified]), type number),
        SortedFiles = Table.Sort(AddYearMonth, {{"Date modified", Order.Descending}}),
        GroupedFiles = Table.Group(SortedFiles, {"Year", "Month"}, {
            {"AllData", each _, type table}}),
        AddIndexAndFilter = Table.TransformColumns(GroupedFiles, {
            "AllData", each Table.FirstN(Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type), 3)
        })
    in 
    
    AddIndexAndFilter

     

    Ensuite tu developpes la colonne Data et tu gardes les colonnes que tu veux