Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

CountIf power bi error

I'm trying to add in a measure that counts the different work types similar to what you can do with a countif, but when I create the dax I get the following error. 

 

I can't figure out how to sort this?

 

 

 

WRK Count = CALCULATE(COUNTA('Daily'[Wrk_Type]),FILTER('Daily','Daily'[Wrk_Type]))

 

 

 

 

 

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a measure. 

    WRK Count =
    CALCULATE (
        COUNTA ( Daily[Wrk_Type] ),
        FILTER ( 'Daily', 'Daily'[Wrk_Type] = MAX ( 'Daily'[Wrk_Type] ) )
    )
    

    (3) Then the result is as follows.

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

6 Replies

  • Hi Anonymous ,
    "Daily"[Wrk_Type] column is a text column type or T/F column type ?
    Can you share a sample dataset so that i could understand the issue clearly ?
    Thanks,
    Pratyasha .

    • Anonymous's avatar
      Anonymous
      Not applicable

      See example of work types. What I am looking for is to add in a measure to count the number of times that a particular work type appears in the example below. Something similar to what can be done in a CountIf formula in excel.

      And to confirm, yes, this is a text a coulmn

       

       

      • pratyashasamal's avatar
        pratyashasamal
        Icon for Memorable Member rankMemorable Member

        Hi Anonymous ,
        Try to use ALL , ALLSELECT Or ALLEXCEPT according to your need in place of Filter function .
        Thanks ,
        Pratyasha Samal

        Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
        If you found this post helpful, please give Kudos C

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a measure. 

    WRK Count =
    CALCULATE (
        COUNTA ( Daily[Wrk_Type] ),
        FILTER ( 'Daily', 'Daily'[Wrk_Type] = MAX ( 'Daily'[Wrk_Type] ) )
    )
    

    (3) Then the result is as follows.

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.