+ Reply to Thread
Results 1 to 5 of 5

counting distinct values within different sub-ranges

  1. #1
    Registered User
    Join Date
    07-06-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    2

    counting distinct values within different sub-ranges

    Hi Community,

    This is my first post, I hope you will be able to help me

    I am trying to do 2 counts. Firstly, a count of the number of devices that are being used in each ward of the hospital.

    Secondly, a count of the number of patients in each ward in the hospital.

    I have attached sample data with the manually calculated results.

    Many thanks
    Leeroy
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,421

    Re: counting distinct values within different sub-ranges

    In G4 copied down:

    =SUMPRODUCT((1/(COUNTIF($C$4:$C$11,$C$4:$C$11))*($B$4:$B$11=F4)))

    G5 in your WB is inaccurate.

    In H4 copied down:

    =COUNTIF($B$4:$B$11,F4)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,887

    Re: counting distinct values within different sub-ranges

    You could also add the table to the data model and do a pivot using distinct count for the patient.
    Rory

  4. #4
    Registered User
    Join Date
    07-06-2020
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    2

    Re: counting distinct values within different sub-ranges

    Thanks AliGW . Those formulas worked. However, when trying to adjust the formula so that it looks at all of column B & C (except B1:C3) i get back #DIV/0! I tried to change the formula to this


    =SUMPRODUCT((1/(COUNTIF($C$4:$C$1048576,$C$4:$C$1048576))*($B$4:$B$1048576=K4)))

    Any ideas?

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,421

    Re: counting distinct values within different sub-ranges

    I imagine the real data has blank rows.

    Please provide a more realistic sample dataset.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Counting distinct values in relation to text values in a separate coulumn
    By Streatty in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-06-2019, 11:04 AM
  2. [SOLVED] Count of distinct values between two date ranges
    By HKPHOOY in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 03-01-2018, 02:39 PM
  3. Counting distinct values in Excel
    By ca16 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-26-2016, 12:42 PM
  4. [SOLVED] Counting distinct values with blank cells produces #DIV/0!
    By antexity in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-14-2015, 09:00 AM
  5. [SOLVED] counting unique/distinct values (sample data attached)
    By justinhampton81 in forum Excel General
    Replies: 9
    Last Post: 08-06-2014, 12:41 AM
  6. Replies: 2
    Last Post: 10-05-2011, 12:30 PM
  7. Counting Distinct Values
    By giantwolf in forum Excel General
    Replies: 4
    Last Post: 12-29-2005, 11:03 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1