Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jtownsend21
Responsive Resident
Responsive Resident

Partition Over - Lookup

I have the following sample data: 

PropertyOwner NameCodeCounty
1ABC Co123Dallas
2ABC Co Tarrant
3Ex. Inc456Dallas
4Ex. Inc Collin
5XYZ LLC Harris
6XYZ LLC789Dallas
7ABC Co Harris
8Ex. Inc Tarrant
9Ex. Inc456Dallas
10ABC Co123Dallas

 

I would like to have the code column populate the code for each company based on the value associated with that company regardless of the county. E.g. all the ABC Co would populate with '123'. 

 

I have tried to do a calculated column with the following, but It is not working like I hoped. 

*OwnerCode* = 
VAR _OwnerName = 'Table'[OwnerName]
RETURN
    MAXX(
        FILTER(
            'Table',
            'Table'[OwnerName]  = _OwnerName &&
            NOT(ISBLANK('All Counties'[Code]))
        ),
        MAX('Table'[Code])
)

I thought about a a lookup and creating a summary table in the function, but not sure exactly how to do that. Open to other ideas. Thank you. 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

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


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

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


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix  so simple. I was way over complicating that problem. 

 

Thank you. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.