Forum Discussion

kent-culpepper's avatar
kent-culpepper
Frequent Visitor
2 years ago

List.Max function @ Power Query M (Inline Subquery)

I am trying to Add a Column ("Max_Quote_Date") that returns the Max Date of another Column ("Quote_Date") with 2 conditions ("Investment_Key","Month_Date"), using the following expression;

 

 

#"Added Max Quote Date" = Table.AddColumn(#"Filtered Rows1", "Max_Quote_Date", each 
    List.Max(#"Filtered Rows1"[Quote_Date], 
            [Investment_Key] = #"Filtered Rows1"[Investment_Key] and [Month_Date] < #"Filtered Rows1"[Month_Date]
        )
    )

 

 

It doesnt seem to be applying both conditions. And the performance is very slow.. I am sure there is a more efficient method.

 

Below is a visual illustration of what i am trying to achieve;

 

I liken this to an "inline subquery" in terms of SQL.

 

Any ideas?

 

Thanks much for your support.

5 Replies

  • Hi,

    If you are amenable to the idea of solving it with a calculated column DAX formula, then share some data to work with (in a format that can be pasted in an MS Excel file).

  • firstly, the conditions are unclear, try to explain in words what you want and what conditions must be met
    secondly, share data that will help you

    • kent-culpepper's avatar
      kent-culpepper
      Frequent Visitor

      Where 

      [Investment_Key] = #"Filtered Rows1"[Investment_Key] and [Month_Date] < #"Filtered Rows1"[Month_Date]

      • Ahmedx's avatar
        Ahmedx
        Super User

        [Investment_Key]  this is Value
         #"Filtered Rows1"[Investment_Key]  this is List
        why do you want to compare the value with the List๐Ÿ™„

        so I ask what do you need?