cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
drwillparry Regular Visitor
Regular Visitor

Measure calculating difference between two distinct counts not giving correct answer

Hi there,

I have two columns in a table visualisation, which show the distinct counts of ID fields. I have also created a measure which should just show the difference between the distinct counts:


Difference = DISTINCTCOUNT(dat4[id]) - DISTINCTCOUNT(dat4[GIN.Number])

 

...but it isn't working. In the image below, you can see that the difference is correct for some entries and not for others. Anyone know why this might be?

 

Regards,

Will

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Measure calculating difference between two distinct counts not giving correct answer

Hi @drwillparry,

 

Yes, the value of "Count (Distinct)" setting in the visual is equal to the measure with COUNT and DISTINCTCOUNT function.

 

Capture.PNG

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
5 REPLIES 5
drwillparry Regular Visitor
Regular Visitor

Re: Measure calculating difference between two distinct counts not giving correct answer

On further investigation, it seems that the DISTINCTCOUNT function is giving a different count to using the 'Count (Distinct)' value setting in the table visualisation. Anyone know why this would be?

 

I added two measures of just the DISTINCTCOUNT(id variable) to the table visualisation, and as you can see, the counts are different (see 04/08/2018)...

 

 

Capture.JPG

 

Regards,

Will

drwillparry Regular Visitor
Regular Visitor

Re: Measure calculating difference between two distinct counts not giving correct answer

I think it must be to do with blanks in one of the ID fields. I think that the visualisation Count (Distinct) setting must count (blank) as a distinct value, whereas the DISTINCTCOUNT function does not.

 

Will

Community Support Team
Community Support Team

Re: Measure calculating difference between two distinct counts not giving correct answer

Hi @drwillparry,

 

The fucntion COUNT and DISCOUNT are different. Here is a simple example, you may could see the difference from the image below.

 

Capture.PNG

You also could have a good look at the document about COUNT and DISTINCTCOUNT function.

 

If you still need help, please feel free to ask.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
drwillparry Regular Visitor
Regular Visitor

Re: Measure calculating difference between two distinct counts not giving correct answer

Hi Cherry, 

I was using the "Count (Distinct)" setting in the visual, so assumed it would return the same count as using DISTINCTCOUNT in DAX.

 

Regards,

Will

Community Support Team
Community Support Team

Re: Measure calculating difference between two distinct counts not giving correct answer

Hi @drwillparry,

 

Yes, the value of "Count (Distinct)" setting in the visual is equal to the measure with COUNT and DISTINCTCOUNT function.

 

Capture.PNG

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.