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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
frankvb
Helper III
Helper III

Sum of a Measure per category

Hi,

 

I am new here, so possibly this is a stupid question.

I want to have a measure that gives me the amount of collaborations between partners on projects

Im working in powerBI via a direct connection to analysis services. That means I can only add measures.

 

My data looks a bit like this:

 

project

partner

Status

month

A

X

positive

june 

A

Y

positive

june

B

X

negative

september

B

Z

negative

september

B

W

negative

september

so If I have 3 partners, I would have 2 collaborations.

 

I have to count the number of collaborations per project with the formula:   Σ N*(N-1)/2

 

Is this possible in a measure? 

I cant really figure out how to make it work so it counts per project AND gives me a proper sum.

What I do right now is the following measure, and then in my report filter by project.

 

calculate(
(distinctcount(table[partner]) *
(distinctcount(table[partner])-1) / 2),
table[status]= "positive"
)
This gives a correct result per project, but of course my total is off, as it computes the formula for everything, and doesnt add up the numbers of each project.

Thank you in advance!
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@frankvb , Try like

sumx(values(Table[project]) ,calculate(
(distinctcount(table[partner]) *
(distinctcount(table[partner])-1) / 2),
table[status]= "positive"
))

 

or

 

averageX(values(Table[project]) ,calculate(
(distinctcount(table[partner]) *
(distinctcount(table[partner])-1) / 2),
table[status]= "positive"
))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
frankvb
Helper III
Helper III

@amitchandak 

I checked the results and it looks like exactly what I needed, thanks! 😊

 

amitchandak
Super User
Super User

@frankvb , Try like

sumx(values(Table[project]) ,calculate(
(distinctcount(table[partner]) *
(distinctcount(table[partner])-1) / 2),
table[status]= "positive"
))

 

or

 

averageX(values(Table[project]) ,calculate(
(distinctcount(table[partner]) *
(distinctcount(table[partner])-1) / 2),
table[status]= "positive"
))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks amitchandak!

 

(this post was edited)

Now I am getting some values! I will validate and let you know if it was what i needed.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.