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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
DanFromMontreal
Helper III
Helper III

Address having 2 or more Zipcode

Dear community,

I just can't figure out how to create a table just like the one below.

I want to identify anomalies in our customer database.

Each address should have a unique Zipcode but I found some having more than 1.

I have a dataset of more then 30K records, so it cannot be done manually.

How can I use PowerQuery to create this table???

Thank you for your support

 

Address   #record in dataset      #of different Zipcode

ABC                      3                                   1

CDE                     14                                  3

FGH                     10                                  1 

...

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Hi @DanFromMontreal ,

 

I created a data sample:

Eyelyn9_0-1647932650093.png

Please simply use "Group by" to get the count and distinctCount:

Eyelyn9_1-1647932733488.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

try this

 

let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIEYUOlWJ1opSQg0wiEjcDcZCDTGISNwVyYYiOoNIhvAsImcM3mQGxqCuamAplmIGyGImturhQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [address = _t, zipcode = _t, otherthink = _t]),
    #"Modificato tipo" = Table.TransformColumnTypes(Origine,{{"address", type text}, {"zipcode", Int64.Type}, {"otherthink", Int64.Type}}),
    #"Raggruppate righe" = Table.Group(#"Modificato tipo", {"address"}, { {"ziplist", each List.Count(List.Distinct([zipcode]))}})
in
    #"Raggruppate righe"

 

 

PS

 

what you have left out is to load an example table with the starting data and a table with the desired result

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @DanFromMontreal ,

 

I created a data sample:

Eyelyn9_0-1647932650093.png

Please simply use "Group by" to get the count and distinctCount:

Eyelyn9_1-1647932733488.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Great explanation @Anonymous

If I understand correctly, it works only if there is only 2 columns in my table (Address, Zipcode).

My table has 10 different columns.  I had to remove all of them and keep only the Address & Zipcode to make it work.

What if I wanted to add a column to have a Distinct count from another column, such as Customer?

The aggregate function would not work 

 

#Address      #Record in dataset        #Distinct Zipcode              #Distinct Customer  

 

Regards,

Anonymous
Not applicable

Immagine 2022-03-17 200431.pngYou should groupby Address and get count and list of ZipCode.

 

 

let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Pcy5DQAwCEPRXVynyUWGQRS59l8hmCLFk74lhComEjJlWFIsz0Il5vasVGPyuFGLeTw79ZjXU0j+q0EDZg8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [address = _t, zipcode = _t, otherthink = _t]),
    #"Modificato tipo" = Table.TransformColumnTypes(Origine,{{"address", type text}, {"zipcode", Int64.Type}, {"otherthink", Int64.Type}}),
    #"Raggruppate righe" = Table.Group(#"Modificato tipo", {"address"}, {{"Conteggio", each Table.RowCount(_), Int64.Type}, {"ziplist", each _[zipcode]}})
in
    #"Raggruppate righe"

 

Rocco,

Tested your solution and it does not fully answer my need.

I was able to regroup to obtain the number of record in dataset (conteggio).

But the part of having the number of DIFFERENT zipcode for each address, that, your solution does not provide.

Again, in my example, for the address CDE, there is 14 records and out of those 14 addresses, there is 3 different zipcode associated to it.

 

Am I missing something?

Thank you for your support.

 

 

Anonymous
Not applicable

try this

 

let
    Origine = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTIEYUOlWJ1opSQg0wiEjcDcZCDTGISNwVyYYiOoNIhvAsImcM3mQGxqCuamAplmIGyGImturhQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [address = _t, zipcode = _t, otherthink = _t]),
    #"Modificato tipo" = Table.TransformColumnTypes(Origine,{{"address", type text}, {"zipcode", Int64.Type}, {"otherthink", Int64.Type}}),
    #"Raggruppate righe" = Table.Group(#"Modificato tipo", {"address"}, { {"ziplist", each List.Count(List.Distinct([zipcode]))}})
in
    #"Raggruppate righe"

 

 

PS

 

what you have left out is to load an example table with the starting data and a table with the desired result

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors