Forum Discussion

njxfoster's avatar
njxfoster
Icon for Helper I rankHelper I
4 years ago
Solved

How to If text column CONTAINS specified value, Then Count it

Hi Everyone,

 

I'm trying to create a calculated measure in one of my tables that help me count every column that contains the word "Warm".

 

How can I implement CALCULATE(COUNTROWS to achieve this function? 

 

 

Thank you

  • VahidDM's avatar
    VahidDM
    4 years ago

    Hi njxfoster 

     

    Try this measure:

    Measure =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER ( 'Table', CONTAINSSTRING ( 'Table'[Connection Details], "Warm" ) )
    )

     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/

     

     

3 Replies

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

    Hi,

    Here is one way to do this:

    CountWarm = COUNTROWS(
    FILTER(
    ADDCOLUMNS(Temperature,"Test",
    if(SEARCH("Warm",Temperature[Temperature],,2)<>2,1,0)),[Test]=1))


    End result:

    I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!



    • njxfoster's avatar
      njxfoster
      Icon for Helper I rankHelper I

      Hi ValtteriN! Thank you for your answer

       

      The table is for phone transfer detail, There is a column about "Connection Details". I need to see how many phone connection is being " Warm transfered"  So I was thinking to count columns that contain the word "Warm" .

       

      is there any way to count this without creating new column?

       

      Thanks in advance

      • VahidDM's avatar
        VahidDM
        Icon for Super User rankSuper User

        Hi njxfoster 

         

        Try this measure:

        Measure =
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( 'Table', CONTAINSSTRING ( 'Table'[Connection Details], "Warm" ) )
        )

         

         

        If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
        Appreciate your Kudos!!
        LinkedIn: 
        www.linkedin.com/in/vahid-dm/