Forum Discussion

damit23183's avatar
damit23183
Microsoft Employee
6 years ago
Solved

Count not working as expected

Hi,

 

Need help on Count.

Please see below details where you can see what i have and what i am looking for.

This is what i have;

 

Source Table:

 

 

 

 

Result I am getting: 

Total Where no of Days < 45: This is column where i am calculating IDs where no of days are less than 45. In this case, we have only one row but i am getting 1 in each row.

 

 

Expected Result should be: I am trying to count how many IDs are has Less than 45 number of days. In this case, we have only one ID so result should be like this;

 

 

Thanks

  • Hi damit23183 

    if your Total column is Column, not a measure, try

    CALCULATE(DISTINCTCOUNT('Table'[Id]), ALLEXCEPT('Table', 'Table'[Id]), 'Table'[Total] < 45, 'Table'[Total] > 0)

     

  • Hi damit23183 ,

     

    You can try creating a measure as shown below in the screenshot:

     

    NOTE: Replace 'Region' in the DAX above with your table name.

     

    If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

     

    Thanks,

    Pragati

5 Replies

  • az38's avatar
    az38
    Community Champion

    Hi damit23183 

    if your Total column is Column, not a measure, try

    CALCULATE(DISTINCTCOUNT('Table'[Id]), ALLEXCEPT('Table', 'Table'[Id]), 'Table'[Total] < 45, 'Table'[Total] > 0)

     

    • damit23183's avatar
      damit23183
      Microsoft Employee

      Thank you for your quick response.

      Really Appreciate it.

      Your formula also worked perfectly as expected.

       

      Thanks

  • Hi damit23183 ,

     

    You can try creating a measure as shown below in the screenshot:

     

    NOTE: Replace 'Region' in the DAX above with your table name.

     

    If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

     

    Thanks,

    Pragati

    • damit23183's avatar
      damit23183
      Microsoft Employee

      Thank you for your quick response.

       

      Really Appreciate it.

       

      Your formula also worked perfectly as expected.

       

      Thanks

  • Anonymous's avatar
    Anonymous
    Not applicable
    Hi, I am using below formula to compute for the estimate, however it doesn't return the correct value.

    DIVIDE (
    CALCULATE
    (COUNTA('Data'[AccPreparation]),
        'Data'[AccPreparation] = "Within Estimate",
    CALCULATE(
        COUNTA('Data'[AccPreparation]), ALL (Data[AccPreparation])))