Forum Discussion

shavish's avatar
shavish
Icon for Helper I rankHelper I
1 year ago

Incorrect measure on card level

Hello all,

 

I have following measure "CALCULATE(COUNTROWS(SHEET1[Category],SHEET1[Category]="Medicine"). The measure is viaulized in the card. 

 

When i look for the actual entries in the table with filters, i am seeing 850 data but the card is showing the count as 750. Any idea what is wrong or please let me know what debug steps i could do to see where the numbers are missing from?

6 Replies

  • Hi shavish 
    Try :CALCULATE(COUNTROWS(SHEET1[Category]),filter('sheet1',SHEET1[Category]="Medicine"))
    If it won't work 

    Please provide a workable sample data and your expected result from that. It is hard to figure out what you want to achieve from the description alone.  

    https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216

     

     

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

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

      Due to confidentiality purpose, i can't share the data. 

  • Hi,

    I am surprised that your measure is not returning an error.  the COUNTROWS() function accepts only a table as an input (not a column). Anyways, try this

    Measure = CALCULATE(COUNTROWS(SHEET1),SHEET1[Category]="Medicine")

    If you do not get the expected result, then check for any filters being applied to the page/report.

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

      Another point, when selecting the category as "Syringes", the number matches excel. So am not sure where the problem is

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from Ashish_Mathur and Ritaf1983 , please allow me to provide another insight:

    Hi, shavish 

    Could you please let me know if the responses from Ashish_Mathur and Ritaf1983 have resolved your issue? If they have, kindly accept their answers as the solution

    Firstly, as Ashish_Mathur mentioned, your measure is returning an error in my practical tests.

    Here is my sample data:

    You might consider trying the following measure:

     

    Measure 2 = COUNTROWS(FILTER('SHEET1', 'SHEET1'[Category] = "Medicine"))
    Measure 3 = COUNTX(FILTER('SHEET1','SHEET1'[Category]="Medicine"),'SHEET1'[Category])
    

     

    Of course, Ashish_Mathur 's measure is also a commendable solution.

     

    Measure = CALCULATE(COUNTROWS('SHEET1'),FILTER('SHEET1','SHEET1'[Category]="Medicine"))
    

     

    The final result is as follows:

     

    For further details, please refer to:
    Filter functions (DAX) - DAX | Microsoft Learn

    COUNTROWS function (DAX) - DAX | Microsoft Learn

    COUNT function (DAX) - DAX | Microsoft Learn

     

    Please find the attached pbix relevant to the case.
     

    Best Regards,

    Leroy Lu

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