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
DaveAA
Regular 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
Anonymous
Not applicable

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.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

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.

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.