Forum Discussion

jtownsend21's avatar
jtownsend21
Icon for Responsive Resident rankResponsive Resident
7 years ago
Solved

Partition Over - Lookup

I have the following sample data:  Property Owner Name Code County 1 ABC Co 123 Dallas 2 ABC Co   Tarrant 3 Ex. Inc 456 Dallas 4 Ex. Inc   Collin 5 XYZ LLC   Harr...
  • MFelix's avatar
    7 years ago

    Hi jtownsend21 ,

     

    You can do this on one of two ways in Query editor or in DAX calculated column:

     

    Query Editor:

    • Sort Columns by OwerName (no matter the sort)
    • Sort again by Code (Descending order)
    • Fill Down the code
    • Reorder by Property

     

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJ0clZwzgcyDI2MgaRLYk5OYrFSrE60khGyrAIQhyQWFSXmlYAlQWpdK/QUPPOSgSwTUzNUvSYo0iDNzvk5OZl5YElTIDciMkrBx8cZKukBNDkTotMMRdLcwhLVYHN0RyFptcCwFNnFlvhdbGiAOzBiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Property = _t, #"Owner Name" = _t, Code = _t, County = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Property", Int64.Type}, {"Owner Name", type text}, {"Code", Int64.Type}, {"County", type text}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Owner Name", Order.Ascending}, {"Code", Order.Descending}}),
    #"Filled Down" = Table.FillDown(#"Sorted Rows",{"Code"}),
    #"Sorted Rows1" = Table.Sort(#"Filled Down",{{"Property", Order.Ascending}})
    in
    #"Sorted Rows1"

    Calculated Column in DAX:

     

    Column = CALCULATE(MAX('Table'[Code]);ALLEXCEPT('Table';'Table'[Owner Name]))

     

    Regards,

    MFelix