Forum Discussion

DataAnalyst13's avatar
DataAnalyst13
New Member
4 years ago
Solved

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!

  • 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.

2 Replies

  • truptis's avatar
    truptis
    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.

  • 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"})) )