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
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 |
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 |
---|---|
124 | |
87 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |