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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Moehimby
Helper II
Helper II

Sum values of column A only if column B is unique

Hey all, I'm stuck and need your expertise, appreciate any help in advance.

 

I have a table organized by ZIP Codes, problem is it has duplicates because some ZIPs are shared between 2 or more customers. 

Is there a way to have the measure only SUM houses for each unique ZIP code? Example of data :

ZIP CodeHousesCustomer
9021025John
90211100Rick
90211100Sandy
9021215John

 

So as you'd see in the above ZIP 90211 will return 200 as the sum of houses, when it should in fact be 100.

 

I've tried approaches like 

CALCULATE( SUM ( 'table'[Houses]) , VALUES( 'table'[ZIP Code] ) but to no avail, it returns the same over stated values every time.... also tried exchanging VALUES for DISCTINCT but same results again.



1 ACCEPTED SOLUTION
hnguy71
Super User
Super User

Hi @Moehimby ,

That's possible but that means only Rick or Sandy would get the 100. Is there a business logic to break ties? If all you're interested in the total, here's a version that may work for you:

SUMX(
    SUMMARIZE (
        'Table',
        'Table'[ZIP Code],
        "@AdjustHomes", DIVIDE(SUM('Table'[Houses]), DISTINCTCOUNT('Table'[Customer]))
    ),
    [@AdjustHomes]
)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hello,hnguy71 and Ashish_Mathur,thanks for your concern about this issue.

Your answers are excellent!
And I would like to share some additional solutions below.


Hi,@Moehimby.I am glad to help you.

After my testing, the advice given by hnguy71 is helpful. Defining a virtual table in measure can create a new computing environment for measure without being affected by the VISUAL that the current measure is in. I think using virtual tables is really a good choice. 

vjtianmsft_0-1739760280509.pngvjtianmsft_1-1739760286234.png

The code of the measure creates a new table where each zip code corresponds to an adjusted number of houses. The adjusted number of houses is calculated by dividing the total number of houses by the number of unique clients. This method can help calculate the distribution of houses under each zip code.

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian

Ashish_Mathur
Super User
Super User

Hi,

Just drag the ZIP code to the Table visual and write this measure

Measure = min('table'[Houses])


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
hnguy71
Super User
Super User

Hi @Moehimby ,

That's possible but that means only Rick or Sandy would get the 100. Is there a business logic to break ties? If all you're interested in the total, here's a version that may work for you:

SUMX(
    SUMMARIZE (
        'Table',
        'Table'[ZIP Code],
        "@AdjustHomes", DIVIDE(SUM('Table'[Houses]), DISTINCTCOUNT('Table'[Customer]))
    ),
    [@AdjustHomes]
)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 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