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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.