Forum Discussion

Daniel_B's avatar
Daniel_B
Helper II
6 years ago
Solved

COUNTIF multiple column criteria selections

Hi All

 

Another simple one I'm hoping to get some help with to boost my learning (YouTube is a minefield!!)

 

I have 2 columns - Sentiment (contains various sentiment values) & Theme (contains themes derived from my made-up data)

 

I want to count the number of times the text "Positive" appears under SENTIMENT in the same row as the word "Person" under THEME so that I can calculate the % of the number of times a Person is considered Positive

 

I've already created a measure for the Total Number of Rows but if there is an easier way of incorporating that into a single formula that would be much better as I want to learn the cleanest method of coding possible 

 

Thanks


Dan_B

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi, Daniel_B 


    If I understand you correctly, you want to divide the number of times a Person is considered Positive by the total number of rows in one formula. In this case , try the following DAX:

     

    Result =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( 'Table', [Sentiment] = "Positive" && 'Table'[Theme] = "Person" )
    )
        / 
            COUNTROWS ( 'Table' )
     

     

    Please leave a message for any updates. 

    Best,
    Paul

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Daniel_B 


    If I understand you correctly, you want to divide the number of times a Person is considered Positive by the total number of rows in one formula. In this case , try the following DAX:

     

    Result =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( 'Table', [Sentiment] = "Positive" && 'Table'[Theme] = "Person" )
    )
        / 
            COUNTROWS ( 'Table' )
     

     

    Please leave a message for any updates. 

    Best,
    Paul

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

  • kentyler's avatar
    kentyler
    Solution Sage

    Could you post a small table of sample data and the text of the measure you created?