+ Reply to Thread
Results 1 to 4 of 4

Countrows help

Hybrid View

  1. #1
    Registered User
    Join Date
    08-30-2016
    Location
    United States
    MS-Off Ver
    MS Office 2016
    Posts
    12

    Countrows help

    Hello,

    I have a dax measure that counts rows based on a start and end time. The measure works except when the start and end time crosses midnight. I need help altering the measure to look at the date as well to get an accurate count. file is attached.

    Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Countrows help

    Your attachment makes no sense

    Try

    A15 =TIMEVALUE(TEXT(A11,"hh:mm:ss"))
    B15 =TIMEVALUE(TEXT(B11,"hh:mm:ss"))
    C15 =IF(INT(B11)>INT(A11),1-A15+B15,0)
    Attached Files Attached Files
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    08-30-2016
    Location
    United States
    MS-Off Ver
    MS Office 2016
    Posts
    12

    Re: Countrows help

    Not sure if I explained my problem well enough. I'm not looking for a calculation between the start and exit time. I'm looking for a count in my hour pivot table. So for the last data entry for 9/1/19 12:22 to 9/2/19 2:05, I want a 1 in the 23:00, 0:00, 1:00, and 2:00 rows.

    My measure works fine if the start date/time < end date/time, but anything that crosses midnight does not count.

    Hope that makes sense.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,824

    Re: Countrows help

    Not sure how/if it can be done with a DAX measure, however here is a formula based proposal.
    Populate a column of discrete hours 0:00 ... 23:00
    The adjacent column is populated using:
    Formula: copy to clipboard
    =SUM(SUMPRODUCT((MOD(Table1[Arrival],1)>=I2)*(MOD(Table1[Arrival],1)<SUM(I2,1/24))),SUMPRODUCT((MOD(Table1[Exit],1)>=I2)*(MOD(Table1[Exit],1)<SUM(I2,1/24))),SUMPRODUCT((MOD(Table1[Arrival],1)<I2)*(MOD(Table1[Exit],1)>=SUM(I2,1/24))),SUMPRODUCT((INT(Table1[Arrival])<INT(Table1[Exit]))*(MOD(Table1[Exit],1)>=I2)))-SUMPRODUCT((INT(Table1[Arrival])<INT(Table1[Exit]))*(MOD(Table1[Exit],1)>=I2)*(MOD(Table1[Exit],1)>=I2)*(MOD(Table1[Exit],1)<SUM(I2,1/24)))

    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. DAX - calculate % of Grand Total using COUNTROWS
    By _eNVy_ in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 04-03-2020, 05:17 AM
  2. Excel DAX Countrows with to
    By Hassan1977 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-22-2017, 12:24 PM
  3. [SOLVED] countrows
    By KBSH in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2017, 11:45 AM
  4. [SOLVED] [SOLVED] Help with Countrows functionality within a Macro
    By Pank in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 07-11-2005, 03:05 PM

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