March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi
I been trying different solutions for this topic but I can't get it to work.
I need to distinct count the barcode with 2 filters and that is "FalseCall" from OperatorJudgement and "Acceptable" from OperatorNgType
Here is the table
Barcode | OperatorJudgement | OperatorNgType |
1678564 | Ng | Acceptable |
1678564 | Ng | Solder Bridge |
1678565 | FalseCall | |
1678565 | Ng | Acceptable |
1678565 | Ng | Solder Bridge |
1678566 | FalseCall | |
1678566 | Ng | Acceptable |
1678566 | Ng | Solder Bridge |
1678570 | Ng | Acceptable |
1678570 | Ng | Solder Bridge |
1678571 | Ng | Acceptable |
1678571 | Ng | Solder Bridge |
1678572 | Ng | Acceptable |
1678572 | Ng | Pin Missing |
1678572 | Ng | Solder Bridge |
1678574 | Ng | Acceptable |
1678574 | Ng | Solder Bridge |
1678574 | FalseCall | |
1678574 | Ng | Acceptable |
1678574 | Ng | Insufficient Solder |
1678574 | Ng | Solder Bridge |
1678575 | Ng | Acceptable |
1678575 | Ng | Solder Bridge |
Solved! Go to Solution.
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")+0
Output:
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.
un ejemplo:
= CALCULATE(DISTINCTCOUNT('Estado de OT'[Orden]),FILTER( 'Estado de OT','Estado de OT'[Estado De OT]<> "Cerrada"))
HI @TcT85 Is this your desired outcome?
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")+0
Output:
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 :
Hi MayharTF,
I used this one as well:
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
Hmm so I need to replace the empty cells with values?
Or is there a way to make the DAX formula to understand this?
Hi @TcT85 ,
You have two choices:
1- fill the empty cells with "Acceptable" value and run the existing DAX code.
2- use the below code for creating the Measure :
It depends on the logic you want it to have. What you have posted acts when both statements are true ("FalseCall" AND "Acceptable"). If you want to show if either of them is true, you should change the code to reflect so like this:
Distinctcount = CALCULATE( DISTINCTCOUNT('SPC DATA'[Barcode]), ('SPC DATA'[OperatorJudgement] = "falsecall") || ('SPC DATA'[OperatorNgType] = "Acceptable"))
Hi paladin21,
Understood but I need both to be true, otherwise I will get the wrong count.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
133 | |
90 | |
88 | |
64 | |
58 |
User | Count |
---|---|
202 | |
137 | |
106 | |
70 | |
68 |