Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Countif in PowerBI

Hi all,

 

I see that there is no countif in PowerBI.

Is there an alternative?

In excel I have applied the formula '=COUNTIF(B6:CN6,">0")'

In PowerBI I am not sure on how to do it.

Can I know how to implement that?

 

Any help is appreciated!

 

Thank you!

Megha

  • Hi Anonymous ,
    Create a measure like this 

    Count = CALCULATE(COUNT(TableName[ColumnName]),TableName[ColumnName]>0)
     
    Replace tablename and columnname accordingly
     

    Please accept this as a solution if your question has been answered !!

    Appreciate a Kudos ðŸ˜€

    Connect with me on LinkedIn: https://www.linkedin.com/in/jaideepnema/

2 Replies

  • Hi Anonymous ,
    Create a measure like this 

    Count = CALCULATE(COUNT(TableName[ColumnName]),TableName[ColumnName]>0)
     
    Replace tablename and columnname accordingly
     

    Please accept this as a solution if your question has been answered !!

    Appreciate a Kudos ðŸ˜€

    Connect with me on LinkedIn: https://www.linkedin.com/in/jaideepnema/

  • Hello:

    The COUNTIF in DAX can be done several ways. It depends on how you set up your model and what tables relate to eachother.

     

    If you only have a single table it can also be handled with this:

     

    Confirmed = COUNTROWS(
    Filter(
    TableName,
    TableName[Column that has the info you are counting] = "What you are counting in that column")
     
    If it's a number field than you don't need the "   ".
    )