Forum Discussion

Augustas-ase's avatar
Augustas-ase
Icon for Helper II rankHelper II
4 years ago
Solved

How write powerbi formula Countifs

Hello,

How to write Formula from excel to Powerbi

My formula in excel is =IF(COUNTIFS(L:L;[@VALUE];N:N;"YES")>0;"YES";"NE")

please help me

  • Hi, Augustas-ase ;

    Sorry, is countif not being used correctly on the way as I understand it, or can you share what your results are?
    A simple example and want to output the result, attached to your logic. If we switch to Powerbi from Countif,
    You can use:

    count =
    IF (
        CALCULATE ( COUNT ( [column] ), FILTER ( ALL ( table ), [column1] = "Yes" ) ) > 0,
        "Yes",
        "No"
    )
    


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

12 Replies

  • PC2790's avatar
    PC2790
    Icon for Community Champion rankCommunity Champion

    Try:

     

    If(CALCULATE(COUNTROWS(TableName),FILTER(TableName,TableName[Value]="Yes"))>0,"Yes","No")
    • PC2790's avatar
      PC2790
      Icon for Community Champion rankCommunity Champion

      Are you getting any error?

      Can you share your sample data?

  • Maybe need to use two filters in the formula? Firstly to COUNTIFS(L:L;[@VALUE] after N:N;"YES"..

    • PC2790's avatar
      PC2790
      Icon for Community Champion rankCommunity Champion

      Yes, because there are two criterias in the CountIFs

      Something like Filter(TableName,Condition1 && Condition 2) and then you can enclose it in IF

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Augustas-ase ;

    Sorry, is countif not being used correctly on the way as I understand it, or can you share what your results are?
    A simple example and want to output the result, attached to your logic. If we switch to Powerbi from Countif,
    You can use:

    count =
    IF (
        CALCULATE ( COUNT ( [column] ), FILTER ( ALL ( table ), [column1] = "Yes" ) ) > 0,
        "Yes",
        "No"
    )
    


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Augustas-ase ;

    Is your problem solved? If so, Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.