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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Distinct Count with filter

Hello Guys,

 

I am doing a distinctcount with filter on a column, power bi doesn't return any syntax error but there is no value in the result. I know for sure that there scould be something in there. here is the formula I am applying:

 

ACHIEVED GOAL = CALCULATE(DISTINCTCOUNT(DSM[Driver]), DSM[TOTAL MILES] = 3000).
can someone help me understand why there is no value in ACHIEVED GOAL?
 
Thanks,
Ulrich
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I have test with your measure, it works on my side:

DISTINCT COUNT.PNG

It's suggested to first check your dataset by applying simple filter like "TOTAL MILES is 3000" as @HashamNiaz said.

 

If it does not make sense,please share me with your pbix file after removing sensitive data.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Thank you all for your reply. please let me reformulate my inquiry. look at this table.

Ulmat_0-1624288517892.png

I have a total mile goal set by week which is 3000 for each driver. the total mile for each driver is the sum of miles for everyday. so my result was blank because power bi was evaluating mile/day there was no day where a driver reached 3000 miles. what I need your help with now is how to sum the daily miles in my filter? I am using this formular but it doesn't work.

Ulmat_1-1624289114358.png

 

thanks,

Ulrich

 

 

 

Anonymous
Not applicable

Hi @Anonymous ,

 

I have test with your measure, it works on my side:

DISTINCT COUNT.PNG

It's suggested to first check your dataset by applying simple filter like "TOTAL MILES is 3000" as @HashamNiaz said.

 

If it does not make sense,please share me with your pbix file after removing sensitive data.

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Eyelyn, I am doing this but mine is counting all the raws, including the blank ones. am I missing something?

Ulmat_0-1624297520719.png

it should be 16 instead of 24.

Anonymous
Not applicable

Hi @Anonymous ,

 

According to the screenshot,It seemed that you got the error count in Excel not in Power BI.

Please try :

  • In Excel:

count in excel.gif

  • In Power BI:
Measure = CALCULATE(DISTINCTCOUNT('Table'[Driver1 ID]),FILTER('Table','Table'[Total MILES]>3000))

count in powerbi.PNG

Refer to:

https://stackoverflow.com/questions/1119614/return-empty-cell-from-formula-in-excel

https://exceljet.net/formula/count-cells-that-are-not-blank

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HashamNiaz
Solution Sage
Solution Sage

Hi @Anonymous !

 

Please try filtering your DSM table where [Total Miles] = 3000 from Data view and see if it retunrs any rows;

 

Alternatively you can try below DAX to check your measure;

 

ACHIEVED GOAL = CALCULATE(DISTINCTCOUNT(DSM[Driver]), FILTER(DSM, DSM[TOTAL MILES] = 3000))


 Regards,

Hasham

parry2k
Super User
Super User

@Anonymous the syntax looks ok, it will give you distinct count where Total Miles = 3000

 

if that condition is met you should get the count. Share the sample pbix or data to further look into it?

 

Do you have any other files in the report?

 

Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors