Forum Discussion
Distinct count with multiple filters
- 3 years ago
Hi TcT85 ,
When the DISTINCTCOUNT() function finds no rows to count, it returns a BLANK, otherwise it returns the count of distinct values.
So if you want the both filter to be true and not return blank value, please try:
Distinctcount = CALCULATE( DISTINCTCOUNT('SPC DATA'[Barcode]),'SPC DATA'[OperatorJudgement] = "falsecall", 'SPC DATA'[OperatorNgType] = "Acceptable")+0Output:
If you just want to calculate the barcode with "FalseCall" and "Acceptable" instead of requiring both values on the same line, please try:
Distinctcount2 = VAR _a = SUMMARIZE ( 'SPC DATA', [Barcode], "Flag", IF ( "FalseCall" IN SELECTCOLUMNS ( FILTER ( 'SPC DATA', [Barcode] = 'SPC DATA'[Barcode] ), "OperationJudgement", [OperatorJudgement] ) && "Acceptable" IN SELECTCOLUMNS ( FILTER ( 'SPC DATA', [Barcode] = 'SPC DATA'[Barcode] ), "OperationNgType", [OperatorNgType] ), 1, 0 ) ) RETURN SUMX ( _a, [Flag] )Output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Not sure what you mean ?
But I posted the below code :
--CALCULATE( DISTINCTCOUNT(Sheet48[Barcode]), Sheet48[OperatorJudgement] = "falsecall")
- TcT853 years agoHelper III
Hi MayharTF,
I used this one as well:
Distinctcount = CALCULATE( DISTINCTCOUNT('SPC DATA'[Barcode]), 'SPC DATA'[OperatorJudgement] = "falsecall", 'SPC DATA'[OperatorNgType] = "Acceptable")What happens is that i get no data shown.But if I use these with 1 single filter it works.--CALCULATE( DISTINCTCOUNT(Sheet48[Barcode]), Sheet48[OperatorJudgement] = "falsecall")--CALCULATE( DISTINCTCOUNT(Sheet48[Barcode]), Sheet48[OperatorNgType] = "Acceptable")Im not sure if the blanks in the OperatorNgType mess up the data.- MahyarTF3 years agoMemorable Member
The shown result is True,
Because in your sample data there are not any rows with FalseCall and Acceptable values (I mean together).
Would you please ask you give your Kudos and select it as a solution if it helps you
- TcT853 years agoHelper III
Hmm so I need to replace the empty cells with values?
Or is there a way to make the DAX formula to understand this?