+ Reply to Thread
Results 1 to 7 of 7

Countifs Mutiple Columns and Criteria Times

  1. #1
    Registered User
    Join Date
    05-26-2022
    Location
    USA
    MS-Off Ver
    365
    Posts
    27

    Countifs Mutiple Columns and Criteria Times

    I am attempting to create a heatmap of visits throughout each day of the week. Each visit has at least one beginning time and ending time. Occasionally there will be a second set of times on the same person. I would like to map out how many visits i have going on at each 15 min interval throughout the work week. Is there a draggable formula that I could use to meet all these criteria?

    I have an example set of data and the goal result.

    Quick example:
    Person 1 is here 7:00-7:45
    Person 2 is here 7:15-8:00

    Result
    6:45 - 0
    7:00 - 1
    7:15 - 2
    7:30 - 2
    7:45 - 2
    8:00 - 1
    8:15 - 0
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,889

    Re: Countifs Mutiple Columns and Criteria Times

    Couple of questions...
    If person is there from 7:00 to 7:45 and you count in 15 min interval... Should it not exclude 7:45 (7:45 to 8:00 interval)? Since the person left at 7:45.

    Also, how did you enter time value in each area? While E7 & J14 both show 9:30. Stored value isn't exact match.

    In this case you'll need to use MROUND(Cell,1/24/60) to round to nearest minute to find match.

    However, since you can't use MROUND() on range. You'll either need helper column(s) or use lambda to apply calculation.

    Sample formula to handle time rounding for range... This uses ">=" for end time to match your manual result.

    In K3: Copy down and across.
    Please Login or Register  to view this content.
    There may be better way to do this, but this should get you the result you want.

    Edit: If your time values are exact matches... formula will be simple COUNTIFS + COUNTIFS.
    Please Login or Register  to view this content.
    Last edited by CK76; 04-15-2024 at 04:20 PM.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    05-26-2022
    Location
    USA
    MS-Off Ver
    365
    Posts
    27

    Re: Countifs Mutiple Columns and Criteria Times

    Thank you for this. I have been struggling all day.

    I will be rounding times to the nearest 15 so i want to account for times being rounded down. That is why i would count 9:30 twice. There is also work that is done after the person leaves. This heatmap is for staffing.

    I'm not sure why the times aren't exact matches. I typed the data times for example and drug to fill the heatmap result. Maybe that's why they are different?

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,435

    Re: Countifs Mutiple Columns and Criteria Times

    Please try in K3 and copy to the right and down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Sometimes there is a difference of 1 compared to the expected results.
    This is because the same times in the sheet are not recorded exactly with the same values for some reason.

    Example the 9:30 in D8 has a value of 0.395833333333333,
    but the 9:30 in J14 has the value of 0.395833333333334.

    The latter is strange. When you re-record 9:30 in J14, it also gets the value of 0.395833333333333.

    You can prevent these types of rounding differences by increasing all times in column J by 1 minute (or 1 second).
    Attached Files Attached Files

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,889

    Re: Countifs Mutiple Columns and Criteria Times

    @alo2279

    Yes, drag down operation will introduce floating point error on small decimal values (i.e. time value).
    Typically, I perform most of my time intelligence in data model and use methods in PQ & DAX to handle rounding issues.

    In your case, using either BYROW iteration using LAMBDA function, or adding helper column as I've stated can handle issue arising from floating point error by applying MROUND(Timevalue,1/24/60).

  6. #6
    Registered User
    Join Date
    05-26-2022
    Location
    USA
    MS-Off Ver
    365
    Posts
    27

    Re: Countifs Mutiple Columns and Criteria Times

    thank you for the help

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,889

    Re: Countifs Mutiple Columns and Criteria Times

    You are welcome.
    If you are satisfied with the solution provided. Please mark the thread as solved using thread tools found at top of your initial post.

+ 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] Countifs - 2 different columns, same criteria
    By rayted in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-24-2019, 05:01 AM
  2. [SOLVED] countifs with criteria at same columns
    By shj92922 in forum Excel General
    Replies: 5
    Last Post: 08-26-2018, 10:34 AM
  3. [SOLVED] COUNTIF mutiple criteria in a single range, but with mutiple ranges.
    By Janbi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2016, 06:31 AM
  4. [SOLVED] Countifs with mutiple range
    By qtmandy in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-24-2016, 03:00 AM
  5. [SOLVED] Sumproduct or countifs to count for mutiple criteria
    By Groovicles in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-04-2014, 11:20 AM
  6. [SOLVED] Countifs sum of mutiple criteria
    By xenomorph8472 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-13-2012, 04:17 PM
  7. Summing times based on mutiple criteria
    By wayne75 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-04-2007, 08:47 AM

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