Forum Discussion

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

Count Multiple Cell Values and Without Counting Blank Cell

Please i need help i counting all the value in the cell fileds as unique count without counting the blank cell, and have the total unique count sum up. As shown in the Pictures, please what measures can i use?

 

  • VahidDM's avatar
    VahidDM
    4 years ago

    Hi nosirui54 

     

    If you need a column use this code:

     

    Column =
    CALCULATE (
        COUNT ( 'Table'[Months] ) + COUNT ( 'Table'[Year] )
            + COUNT ( 'Table'[Number] )
            + COUNT ( 'Table'[FIPS] )
            + COUNTA ( 'Table'[Postal_Code] )
            + COUNT ( 'Table'[State] )
            + COUNT ( 'Table'[County] ),
        FILTER ( 'Table', 'Table'[Months] = EARLIER ( 'Table'[Months] ) )
    )

     

     

    Output:

     

    If you need a measure:

    Measure = 
    CALCULATE (
        COUNT ( 'Table'[Months] ) + COUNT ( 'Table'[Year] )
            + COUNT ( 'Table'[Number] )
            + COUNT ( 'Table'[FIPS] )
            + COUNTA ( 'Table'[Postal_Code] )
            + COUNT ( 'Table'[State] )
            + COUNT ( 'Table'[County] ),
        FILTER ( 'Table', 'Table'[Months] = max ( 'Table'[Months] ) )
    )

     

    Output:

     

    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/

     

     

     

     

6 Replies

  • Hi nosirui54 

     

    Can you post sample data as text and expected output?
    Not enough information to go on;

    please see this post regarding How to Get Your Question Answered Quickly:
    https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.
    4. Relation between your tables

    Appreciate your Kudos!!
    LinkedIn:www.linkedin.com/in/vahid-dm/

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

      Thank you for your response. What am trying to achieve is this:
      1. I want each Cells with Values to count as one and then show counts total in the Expected_Output_Counts Column

      2. If the cell is blank it shouldnt count blank cell as value, because is blank

      MonthsYearNumberFIPSPostal_CodeStateCountyExpected_Output_Counts
      January20011100036003AlabamaAutauga7
      February20022100136003AlabamaAutauga7
      March20033100331034AlabamaBaldwin7
      April20044100526238AlabamaBarbour7
      May200551007 TexasValley6
      June200661009   4
      July200771011   4
      August200781011 Texas 5
      • VahidDM's avatar
        VahidDM
        Icon for Super User rankSuper User

        Hi nosirui54 

         

        If you need a column use this code:

         

        Column =
        CALCULATE (
            COUNT ( 'Table'[Months] ) + COUNT ( 'Table'[Year] )
                + COUNT ( 'Table'[Number] )
                + COUNT ( 'Table'[FIPS] )
                + COUNTA ( 'Table'[Postal_Code] )
                + COUNT ( 'Table'[State] )
                + COUNT ( 'Table'[County] ),
            FILTER ( 'Table', 'Table'[Months] = EARLIER ( 'Table'[Months] ) )
        )

         

         

        Output:

         

        If you need a measure:

        Measure = 
        CALCULATE (
            COUNT ( 'Table'[Months] ) + COUNT ( 'Table'[Year] )
                + COUNT ( 'Table'[Number] )
                + COUNT ( 'Table'[FIPS] )
                + COUNTA ( 'Table'[Postal_Code] )
                + COUNT ( 'Table'[State] )
                + COUNT ( 'Table'[County] ),
            FILTER ( 'Table', 'Table'[Months] = max ( 'Table'[Months] ) )
        )

         

        Output:

         

        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/