Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I have a following table,
| Network | patID | Status |
| A | 1 | Approved |
| A | 1 | Approved |
| A | Approved | |
| A | 1 | Approved |
| A | 2 | Declined |
| B | 3 | Approved |
| B | 4 | Approved |
| B | Approved | |
| B | 5 | Declined |
| B | 6 | Approved |
I wanted to write a calculated column called count which return distinct count of patID whose status is approved.
But it should not count the patID if its null,
I wrote the following DAX query,
| Network | patID | Status | count |
| A | 1 | Approved | 2 |
| A | 1 | Approved | 2 |
| A | Approved | 2 | |
| A | 1 | Approved | 2 |
| A | 2 | Declined | 2 |
| B | 3 | Approved | 4 |
| B | 4 | Approved | 4 |
| B | Approved | 4 | |
| B | 5 | Declined | 4 |
| B | 6 | Approved | 4 |
But the expected output was,
| Network | patID | Status | count |
| A | 1 | Approved | 1 |
| A | 1 | Approved | 1 |
| A | Approved | 1 | |
| A | 1 | Approved | 1 |
| A | 2 | Declined | 1 |
| B | 3 | Approved | 3 |
| B | 4 | Approved | 3 |
| B | Approved | 3 | |
| B | 5 | Declined | 3 |
| B | 6 | Approved | 3 |
Please help with the corrected query eliminating the count which invloves blank patID
Solved! Go to Solution.
Hi @Anonymous ,
I think you almost had it!
I just added the <> BLANK() filter to your code:
COUNT =
CALCULATE(
DISTINCTCOUNT ('TABLE'[patID]),
FILTER (
ALL('TABLE'),
'TABLE'[Network] = EARLIER('TABLE'[Network]) && 'TABLE'[Status] = "Approved" && 'TABLE'[patID] <> BLANK()
)
)
Does this solve your issue? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
| Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
| Also happily accepting Kudos 🙂 |
| Feel free to connect with me on LinkedIn! | |
| #proudtobeasuperuser | |
Hi,
This calculated column formula works
CALCULATE(DISTINCTCOUNT(Data[patID]),FILTER(Data,Data[Network]=EARLIER(Data[Network])&&Data[Status]="Approved"&&Data[patID]<>BLANK()))
You do not need the ALL function.
Hi @Anonymous ,
I think you almost had it!
I just added the <> BLANK() filter to your code:
COUNT =
CALCULATE(
DISTINCTCOUNT ('TABLE'[patID]),
FILTER (
ALL('TABLE'),
'TABLE'[Network] = EARLIER('TABLE'[Network]) && 'TABLE'[Status] = "Approved" && 'TABLE'[patID] <> BLANK()
)
)
Does this solve your issue? 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
| Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
| Also happily accepting Kudos 🙂 |
| Feel free to connect with me on LinkedIn! | |
| #proudtobeasuperuser | |
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!