• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Forcing Distinct Counts to sum to total Distinct Count |Power Pivot|Excel Forum|My Online Training Hub

You are here: Home / Forcing Distinct Counts to sum to total Distinct Count |Power Pivot|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower PivotForcing Distinct Counts to sum to t…
sp_PrintTopic sp_TopicIcon
Forcing Distinct Counts to sum to total Distinct Count
Avatar
Jennifer Owens
Member
Members
Level 0
Forum Posts: 7
Member Since:
June 29, 2022
sp_UserOfflineSmall Offline
1
September 8, 2022 - 5:27 am
sp_Permalink sp_Print

I have a table containing incident-level data for August 2022.  Each incident can have multiple youth involved.  For example, if incident 12345 had 3 youth involved, 3 rows would appear for incident 12345.  Each unique youth can be involved in multiple incidents, so I summarized the values for my Youth ID variable (ID_Youth) by Distinct Count to get the number of unique youth involved in one or more incident in August 2022.  This worked great for the total and even when I broke that total out by Sex and Race; however, it is not working if I break the total out by Age or other variables that might change over time.  As shown in the fake table below, summing across the age categories equals 23, rather than 18. 

Row Labels       Distinct Count of ID_Youth
12 and under                       2
13                                      2
14                                      5
15                                      5
16                                      5
17                                      2
18 and over                         2 
Grand Total                      18

This is because youth can be involved in multiple incidents and Age might change from one incident to another.  Unfortunately, this will confuse my users.  For variables like Age, I would like to classify each youth according to their Age (or other characteristic) as of the first incident they were involved in during the month.  For example, if Jonny was involved in 3 incidents in August, one on 8/10, one on 8/12, and one on 8/25, I'd like to use his age from 8/10.  Is there any way to make this happen?  I thought I could fix this issue by adding a variable to my table coded as 1 for the first incident each unique youth was involved in during the month; however, this leads to issues once slicers are applied.  For example, if I sliced the data below to only look at Assaults, I would lose this youth even though he had two assaults, because my proposed filter for First_Incident would be 0 for both assault records.  For this example, I would love to use the data from 8/22/22, which is the earliest of the records left after the slicer is applied.  

Any help would be much appreciated.  I would hate to have to add notes to all the charts saying "Figures may add to more than the total because ...". 
I find our users get very confused if things don't add.  Thank you!! 

ID_Incident     Incident_DT     ID_Youth      Age     Incident_Type       First_Incident  
12345                   8/10/22             2244            15        Contraband                     1 
12345                   8/10/22             2244            15        AWOL                             1
12345                   8/10/22             2244            15        Restraint                         1
99888                   8/22/22             2244            15        Assault                           0
99888                   8/22/22             2244            15        Hospital/Medical              0
99888                   8/22/22             2244            15        Restraint                         0
99888                   8/22/22             2244            15        Other                              0
10999                   8/28/22             2244            16        Assault                            0
10999                   8/28/22             2244            16        Hospital/Medical               0

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4450
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
September 9, 2022 - 11:55 am
sp_Permalink sp_Print

Hi Jennifer,

I think you need to add another column to your Youth Age table that converts their age based on the first incident of the month. You could do this in Power Query.

I hope that points you in the right direction. If you get stuck, please come back with a small sample Excel file that illustrates the issue so we can help you further.

Mynda

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

Member Stats:
Guest Posters: 49
Members: 31920
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.