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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
neil37
Advocate I
Advocate I

Complicated Distinct Count

Hello, 

 

I am having issues accurately counting occurences of specific crimes due to identical rows that cannot necessarily be removed by "removing duplicates" because the CR, CRno, and Caseno may be the same but the offense may be different. 

 

See Image. DistinctIssue.PNG

 

 

For example: CR is the index column; however, there are more than one CR's when the Offense is different.

 

I want to create a column that has an accurate count of all offenses. DISTINCTCOUNTNOBLANK works okay for a measure, but not sure how to create a new column within my table (or new table) that considers what I mentioned above. 

 

In the screenshot example the occurences would be:

Criminal Arrest Warrant: 1
Robbery: 1
Theft - Motor Vehicle - 1

Tresspass of Real, et al - 1

Resisting . Interfering w/ Police - 1

Obstruct / Tampering et. al - 1

 

Thank you!

5 REPLIES 5
Fowmy
Super User
Super User

@neil37 

You can create a measure to count the distinct Offence count:

Offense Count = COUNTROWS(VALUES(Table[Offense]))

 

Fowmy_0-1603610130328.png

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

AlB
Super User
Super User

Hi @neil37 

You need to explain it a bit more. You want a calculated column in that table?? What for, if you already have a measure that gives you the right result? If you want the calculated column, do the numbers provided mean that you want the given value in each row that has that offense? For instance, you would want all rows where Offense is "Theft - Motor Vehicle" to have a - 1 in the new column? What is the logic for that number? Please show the esample table with the column you want added and the expected results, to clarify

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Hi! Thank you for the quick response!

 

The reason I cannot use the Dinstinctmeasure that I already created  (e.g., =DISTINCTCOUNT('tablename'[caseno])) because the new measure I am creating requires a Table Column (see below):

 

2,DistinctIssue.PNG

 

 

I am attempting to calculate the crime count last year, as well as the Difference between the Current Year and Last Year. I have the measures created but the caseno column is not distinct in the data so the sums are incorrect.

 

I am a bit new to PowerBI so if you have a different formula to use to calculate Last years Crime Count using a distinct count measure and not columns, I am open to suggestions! 

 

Thank you for your help!!

Ultimately, the new calculated column within our table would have a 1 or 0 if that specific row was counted as "distinct" when you instruct PowerBI to "Count(Distinct) within a visualization (That is how we have determined  the most accurate way to count the number of unique crime counts). If that does not make sens,e please let me know and I will try to explain it better.  @AlB  Thank you!!

@neil37 

Sorry. I don't get it 🤔

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors