Forum Discussion

Benjamin_Eureka's avatar
Benjamin_Eureka
Frequent Visitor
4 years ago
Solved

Create conditional column based on table filtered by row data

Hi folks,   I'm trying to create a conditional column with the max value of a certain place on a certain date (see image), but I can't get it to work. I tried to nest a filtered table in a List.Max...
  • ronrsnfld's avatar
    4 years ago

    Here is one method

     

     

     

    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Place", type text}, {"Value", Int64.Type}}),
        
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Max", each 
          let 
            tb= Table.SelectRows(#"Changed Type", (t)=> t[Place] = [Place] and t[Date] = [Date])
          in  
            List.Max(tb[Value]))
    in
        #"Added Custom"

     

     

     

    If you are just using the UI,   Add a custom column with the formula:

    let 
            tb= Table.SelectRows(#"Changed Type", (t)=> t[Place] = [Place] and t[Date] = [Date])
          in  
            List.Max(tb[Value])