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
DataAnalyst13
New Member

Calculating Percentage

Hi Everyone,

 

I'm trying to calculate a percentage. My column consists of YES, NO and NA. What i want to calculate is just NO/(YES + NO).

 

How can i do this in PowerBI?

 

Thank you!

1 ACCEPTED SOLUTION
truptis
Community Champion
Community Champion

Hi @DataAnalyst13 , Try this:

Result =  var count_of_NO = Calculate(count([columnname]), FILTER(tablename, [columnname]="NO"))

var count_of_YES = Calculate(count([columnname]), FILTER(tablename, [columnname]="YES"))
var total =count_of_NO + count_of_YES

RETURN
DIVIDE(count_of_NO, total)

If you wish to include NA too in the toal then you can use this:
var total = count([columnname])

@DataAnalyst13 -> Please hit the thumbs up & mark it as a solution if it helps you. Thank you.

View solution in original post

2 REPLIES 2
truptis
Community Champion
Community Champion

Hi @DataAnalyst13 , Try this:

Result =  var count_of_NO = Calculate(count([columnname]), FILTER(tablename, [columnname]="NO"))

var count_of_YES = Calculate(count([columnname]), FILTER(tablename, [columnname]="YES"))
var total =count_of_NO + count_of_YES

RETURN
DIVIDE(count_of_NO, total)

If you wish to include NA too in the toal then you can use this:
var total = count([columnname])

@DataAnalyst13 -> Please hit the thumbs up & mark it as a solution if it helps you. Thank you.

amitchandak
Super User
Super User

@DataAnalyst13 ,


divide(calculate(count(Table[column]), filter(Table, Table[flag] in {"Yes", "No"})) ,
calculate(count(Table[column]), filter(allselected(Table), Table[flag] in {"Yes", "No"})) )

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.