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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Populate group with most occurring address

I have a dataset that contains many lines of duplicative data with varying differences and need to normalize the list so the most frequent address shows for the group.

 

Example:

 

NameGroup IDAddressNormalized Address
John Doe1123 Broadway 
John Doe1123 Broadway 
John Doe1459 Park Place 
John Doe1123 Broadway 
Jane Doe2456 Lexington 

 

I want to be able to populate the 'Normalized Address' column with "123 Broadway" for all lines associated with Group ID 1 and "456 Lexington" for Group ID 2

 

Desired output:

 

NameGroup IDAddressNormalized Address
John Doe1123 Broadway123 Broadway
John Doe1123 Broadway123 Broadway
John Doe1459 Park Place123 Broadway
John Doe1123 Broadway123 Broadway
Jane Doe2456 Lexington456 Lexington

 

Any help is much apprecaited!

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , you might want to try this,

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFNwyU9V0lEyBGEjYwWnovzElPLESqVYHZLlTUwtFQISi7IVAnISk1OJMyExLxUqbwQ2wUzBJ7UiMy+9JD9PKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Group ID" = _t, Address = _t]),

    #"Added Custom" = Table.AddColumn(Source, "Normalized Address", each List.Mode(Table.Group(Source, {"Group ID"}, {{"All", each _}}){[Group ID=[Group ID]]}[All][Address]))
in
    #"Added Custom"

Untitled.png

 

Screenshot 2020-11-24 230432.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , you might want to try this,

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFNwyU9V0lEyBGEjYwWnovzElPLESqVYHZLlTUwtFQISi7IVAnISk1OJMyExLxUqbwQ2wUzBJ7UiMy+9JD9PKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Group ID" = _t, Address = _t]),

    #"Added Custom" = Table.AddColumn(Source, "Normalized Address", each List.Mode(Table.Group(Source, {"Group ID"}, {{"All", each _}}){[Group ID=[Group ID]]}[All][Address]))
in
    #"Added Custom"

Untitled.png

 

Screenshot 2020-11-24 230432.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

@CNENFRNL Thank you so much! This works perfectly but it takes a long time to execute and I need to run this across many different fields. Any suggestions on how to get this to run faster?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors