cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DaveAA Visitor
Visitor

Measure to divide the sum of one column by the count of another

Hello,

I have 2 columns - column1 contains unique labels, column2 contains a value (1 or 0 that represents yes/no).  I want to sum the values in column2 and divide by the number of occurrences of the unique label over any rows so I can return a % of Y vs. N.

Ecru Uph1
Ecru Uph1
Leesport Uph1
Arcadia Uph1
Arcadia Uph1
Arcadia Uph1
Arcadia Uph0

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Measure to divide the sum of one column by the count of another

CountAll = COUNTROWS('YourTable')

CountYes = CALCULATE(
	[CountAll],
	'YourTable'[Column2] = 1
)

Yes Percent = DIVIDE(
	[CountYes],
	[CountAll]
)

I've split this up into 3 measures so you can call those measures later on, for example if your wanted a No percent.


   

              Did I answer your question? Mark my post as a solution!
       

Proud to be a Datanaut!


   


1 REPLY 1
Highlighted
Super User
Super User

Re: Measure to divide the sum of one column by the count of another

CountAll = COUNTROWS('YourTable')

CountYes = CALCULATE(
	[CountAll],
	'YourTable'[Column2] = 1
)

Yes Percent = DIVIDE(
	[CountYes],
	[CountAll]
)

I've split this up into 3 measures so you can call those measures later on, for example if your wanted a No percent.


   

              Did I answer your question? Mark my post as a solution!
       

Proud to be a Datanaut!