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

Sum of distinct values.

Hi, I have a table which I am trying to process to find out the sum of Input Values for distinct Linked Permit numbers.

I can't delete duplicates, because this is a part of other columns, where I need duplicates.

I am trying to do this and it does not work, how hard I tried.

Sum of all input values = sum(TEST[Input Value])
 Distinct sum = sumx(DISTINCT(TEST[Linked Permit]),[Sum of all input values])
 
Logic tells me that DISTINCT should create a context were only distinct Linked Permits exist, and then SUMX should add all Input Values, but it does not work. Can you please help? I searched everywhere and no help...
 
Capture1.PNG

Capture.PNG

1 ACCEPTED SOLUTION

@Anonymous

Do you mean the version with DISTINCT should sum only once the duplicate rows? When you talk about duplicates, is it the whole row (i.e. all columns) that are duplicated?

If all rows are duplicated, wouldn't the result you want just what you get now divided by two?

Try these measures, a variation of what you had:

 

Sum of all input values = sum(TEST[Input Value])
Number Of Duplicates = COUNTROWS(TEST)
Distinct sum =
SUMX (
    DISTINCT ( TEST[Linked Permit] ),
    DIVIDE ( [Sum of all input values], [Number Of Duplicates] )
)

View solution in original post

3 REPLIES 3
AlB
Super User
Super User

Hi @Anonymous

 

What is the problem exactly? What is the result as opposed to your expected/required result?

Anonymous
Not applicable

The issue is that the result of those measures is literally the same, so no filtering is going on in regards of distinct values (Linked Permit). I think it's visible on the picture above.

@Anonymous

Do you mean the version with DISTINCT should sum only once the duplicate rows? When you talk about duplicates, is it the whole row (i.e. all columns) that are duplicated?

If all rows are duplicated, wouldn't the result you want just what you get now divided by two?

Try these measures, a variation of what you had:

 

Sum of all input values = sum(TEST[Input Value])
Number Of Duplicates = COUNTROWS(TEST)
Distinct sum =
SUMX (
    DISTINCT ( TEST[Linked Permit] ),
    DIVIDE ( [Sum of all input values], [Number Of Duplicates] )
)

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.