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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Sum of distinct rows

Hi,

there are several similar cases, but all these solutions didnt work out for me. Maybe just a simple fault by me.

 

My data is given like this:

 

ID / Customer / gender (1=man, 0=woman) /

 

123   ABC   1

123   ABC   1

124   ABD   0

125   ABE    1

123   ABC   1

126   ABF    0

 

I want to summarize the values given in gender but only for distinct rows.

In this case: 123 should not summarized as 3 - correct would be 1

 

My suggestion: SUMX(DISTINCT(ID);SUM(GENDER))

 

Thanks for your help!

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@v-shex-msft @vanessafvg

Thanks for your help. I solved it now like this:

 

CALCULATE(DISTINCTCOUNT(ID);FILTER(TABLE;Gender=1))

 

Best,

Micha

View solution in original post

you actually dont need the filter

 

CALCULATE(DISTINCTCOUNT(ID),TABLE[Gender]=1)  should work fine





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @Anonymous,

 

You can use countx and distinct function to achieve your requirement.

 

Measure:

Distinct=COUNTX(DISTINCT(ALL(Table1)),[Gender]))

Sample:

Table 2 = SUMMARIZE('Table1',[Gender],"Count",COUNTX(DISTINCT(Table1),[Gender]))

1.PNG

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

@v-shex-msft @vanessafvg

Thanks for your help. I solved it now like this:

 

CALCULATE(DISTINCTCOUNT(ID);FILTER(TABLE;Gender=1))

 

Best,

Micha

you actually dont need the filter

 

CALCULATE(DISTINCTCOUNT(ID),TABLE[Gender]=1)  should work fine





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




vanessafvg
Super User
Super User

@Anonymous

cases = distinctcount(id)

 

if you put your gender on your visual then it should sum up the distinct cases

 

i.e based on your data

 

Gender  No of Cases

1             2

0            2





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.