Forum Discussion

Gryph87's avatar
Gryph87
New Member
3 years ago
Solved

Max Date Values

I am trying to access the records for the most current date on a very large table. Below is a example of the data I am working with.  The "System Number" and "Threshold Type" can have multiple "Date...
  • ronrsnfld's avatar
    3 years ago

    OK, all you need to do is Group By System Number and Threshold Type, then filter each sub table in the Table.Group aggregation:

     

     

    let
    
    //change next line to reflect your actual data source
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    
        #"Changed Type" = Table.TransformColumnTypes(Source,{
            {"Date From", type date}, {"GG", type text}, {"GZ", type text}, {"Threshold Type", type text}, 
            {"Target Avg Factor", type number}, {"Target Min Factor", type number}, 
            {"System Description", type text}, {"System Number", type text}}),
            
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Threshold Type", "System Number"}, {
        
            {"Latest", (t)=>Table.SelectRows(t, each [Date From] = List.Max(t[Date From])), 
            
            type table [Date From=nullable date, GG=nullable text, GZ=nullable text, Threshold Type=nullable text, Target Avg Factor=nullable number, Target Min Factor=nullable number, System Description=nullable text, System Number=nullable text]}}),
        
        #"Expanded Latest" = Table.ExpandTableColumn(#"Grouped Rows", "Latest", {"Date From", "GG", "GZ", "Target Avg Factor", "Target Min Factor", "System Description"})
    in
        #"Expanded Latest"

     

    Results from your data