Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

DAX Distinct Count with Filter

I'm comparing 2 columns; [Ticket Number] and [Scan datetime] in the same table.

I need to find the total number of unique tickets with a scan. I came up with the following formula but not sure if its correct....

TotalAccepScan:=CALCULATE(DISTINCTCOUNT(Table_name[TICKET]),Table_name[ACCEPTANCE_DATETIME]<>BLANK())

 

1 ACCEPTED SOLUTION

@Anonymous - I do not see anything wrong with that calculation. It is probably not how I would have structured it but because I try to avoid using CALCULATE but there is nothing wrong with it if your intention is to get a distinct count of only the TICKET's that have a SCAN_DATETIME.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

That's a very difficult question to answer with the information provided @Anonymous . Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler my apologies. Here is sample dataset.

Output result: What is the count of (unique) tickets that have a scan date? My current formula is:

Total_Tickets_With_Scan:=CALCULATE(DISTINCTCOUNT(Table_Name[TICKET]),Table_Name[SCAN_DATETIME]<>BLANK())

Hope that made sense.

TICKETSCAN_DATETIME
FF16654931728/04/2020 12:52
FF166549626 
FF166549820 
FF166550071 
FF16655032928/04/2020 12:51
FF166550394 
FF166550403 
FF16655044828/04/2020 16:53
FF16655112528/04/2020 17:53
FF166551545 

 

@Anonymous - I do not see anything wrong with that calculation. It is probably not how I would have structured it but because I try to avoid using CALCULATE but there is nothing wrong with it if your intention is to get a distinct count of only the TICKET's that have a SCAN_DATETIME.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler thank you for confirming. Appreciate your help.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.