Forum Discussion

formerlyknownas's avatar
5 years ago
Solved

distinctcount getting multiple hits

Hello! 

I'm trying to get the distinct count function to determine the number of distinct batches we have made. I've used the following logic:

 

 

 

 

 

Unique Batches = CALCULATE (
    DISTINCTCOUNT ('Production'[BatchNum]))

 

 

 

 

 

And when I click in the sample data on each batch, I can see that in most cases, it's working.  For example, B10059 has two batch numbers but is only counted as one, which is expected.

 

 

However, there are a few where it's simply not working.  Here, it's counted three times

 

 

 

Querying the data, I don't see any issue with formatting. BatchNum is definitley the same and should only be counted once.  There are three hits in the data set, but that shouldn't matter in this case if BatchNum has the same value.

 

 

Any idea why I'm not always gettign a distinct count in Power BI? Many thanks in advance. 

 

 

  • Hi formerlyknownas ,

     

    Can you try using the following measure instead?

    Unique Batches = DISTINCTCOUNT('Production'[BatchNum])

     

    There may be a context issue with the previous version.

     

    Pete 

2 Replies

  • Hi formerlyknownas ,

     

    Can you try using the following measure instead?

    Unique Batches = DISTINCTCOUNT('Production'[BatchNum])

     

    There may be a context issue with the previous version.

     

    Pete 

  • Thanks, Pete. I made a new measure according to your suggestion, and it worked. I don't think I created a proper measure the first time around.

     

    Eric