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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
avujica
New Member

Count(distinct) not working

Hi I'm having trouble getting Count(distinct) to work. I have a table that i would like to get a count of the distinct project numbers and the total of lab hours associate with each distinct project #. I can't seem to even get just the distinct count of project #'s working and i would expect to get 14 but all i get ins continuous calculating. I have used both the built in selection within the lab project number field in the values table and I also tried to write my own measure with no luck. Can anyone provide any insight and help ? Thank you very much for your help and consideration.

 

Lab Project NumberTest NumberTotal Lab Hours Used (Test)Test Received WeekTest Completed Week
10007067421170853611010
10007085391049498621015
10007854041160756861021
10007854041175313961021
10007880161177739011012
10007880161177739111012
1000788016117773920.11012
10008197031173723211010
10008197031173723411010
10008197031173723511010
10008620331112572501024
10008622041177415001011
10008688751177206471015
10008688751177208271015
10008688751177210771015
10008688751177210871015
10008688751177210971015
10008989471158396421019
10008989471158396621019
10008989471158396721019
10008989471158396921019
10009005191174599531013
10009038271164245531011
10009038271164245631011
10009077531173449921011
1000907753117357552.51011
10009145661177403461012
10009945541178284151012
10009945541178284351012
10009945541178284551012
10009945541178284651012
10009945541178307421012
6 REPLIES 6
avujica
New Member

@amitchandak , @Greg_Deckler 

 

Hi, thank you very much for the quick replies and taking time to look at my problem. The command works fine if I were to run it on a seperate standalone .xls table but it doesnt run within the report I built. It may be a problem of it looking at my entire data cube/data set rather than just the info that i have filtered to my table and i dont know how to get around that. If i run the command in a seperate (card) visualization it comes back with 1.02 million.. I do not have any page level or report level filters just the 5 visual level filters and values you see in the table headings. I am also running 4 slicers for test recievd week, test completed week, and 2 lab identifiers.

 

Thank you for your help !

amitchandak
Super User
Super User

@avujica , You should be able to get is using

distinctcount(Table[Lab Project Number]), But as the projects are repeating, grand total will not sum up in case you are checking across some other axis/group 

And may observe differences at line level avg and overall average.

 

Can you share sample output in a table format, if the issue not resolved by the last update from Greg?

Hi Thank you for your help but your solution did not help. If you have time please see the post i made in this thread regarding my observations.

 

Thank you again for your help.

Greg_Deckler
Super User
Super User

@avujica - The built-in distinct count works for me. See attached PBIX below sig. You want table 3 page 3


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Thank you for lookinbg at my problem and offering a solution unfortunately its not working as intended. Please note my observation documente din my most recent post in this thread.

Thank you again for your help,

Alan

@avujica hover over the filter icon on the visual when i the desktop and confirm it is filtered as you think it is. I've filter panes and off-paged syncing with hidden slicers on current page messing with filters during DAX debugging.

edhans_0-1598395498587.png

Other than that, you will need to share something with us. You can have filtering happening depending on your filter relationships. Bi-directional possibly, but Many to many will mess with this.  Otherwise it will be very difficult for any of us to figure out the problem by your description alone. On its own, DISTINCTCOUNT() is a pretty basic function, so anything going wrong is a filter or modeling issue, or both.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors