+ Reply to Thread
Results 1 to 9 of 9

Working out a tariff from a date and time

  1. #1
    Registered User
    Join Date
    11-03-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    5

    Working out a tariff from a date and time

    Hi All,

    I am trying to carry out a count on my data whether it falls within the specific parameters:

    Operates on a Monday - Friday,
    Within 05:30 - 09:00 or 15:00 - 19:00.

    I have tried a combination of SUMPRODUCT and COUNTIFS to no avail, so hoping you could lend a helping hand please?

    Data comes in the form of:

    Arrival/Departure date time UTC | Arrival/Departure time UTC
    01-Jan-11 10:50 | 10:50
    01-Jan-11 12:13 | 12:13
    02-Jan-11 12:40 | 12:40
    02-Jan-11 14:07 | 14:07
    02-Jan-11 14:30 | 14:30
    ...

    Thanks in advance,

    Charlie.
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Working out a tariff from a date and time

    Welcome to the Forum!

    I'm not clear on what you're trying to do when you say "whether it falls within." You have arrival and departure in the same column. So do you want to know the count of all times that fall within one of those two ranges? Without regard to what's departure and what's arrival?

    Here is an Excel 2007 formula that will do this:

    =COUNTIFS(B:B,">=0.229166666666667",B:B,"<=0.375")+COUNTIFS(B:B,">=0.625",B:B,"<=0.791666666666667")

    What it does not do: It does not detect whether a given departure/arrival combination intersects one of those ranges. For example, a trip with a departure of 05:00 and an arrival of 09:30 will not be counted.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-03-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Working out a tariff from a date and time

    Thanks for getting back to me 6StringJazzer, and apologies I was not clear.

    You are correct about the arrival/departure part, this is not an issue. I need to count whether the occurrence is within the boundaries for the billing scenario.

    We currently bill our clients on a peak / off peak:

    Peak - Monday to Friday between 05:30 - 09:00 or 15:00 - 19:00.
    Off Peak - All other times Monday/Friday - Saturday and Sunday.

    is there a way we can combine the WEEKDAY from column A and the times from column B to see what % is peak and off peak?

    Many thanks.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Working out a tariff from a date and time

    I would recommend that you have one column for Departure time and another column for Arrival time. This would make this a lot easier. One problem with your data is that there are an odd number of times. So how do departures correspond to arrivals?

    You really need to explain how you want to calculate peak time. For example, if you consider the entire trip "peak" based on departure time alone, then that's different than counting the travel minutes that occur during peak time.

    I have attached an example that calculates the portion of each trip that takes place during peak time. For your data, I have assumed that the first time is a departure and the second is arrival, and so on. However, that doesn't seem to make sense for your data, so you'll have to explain it.

    I also haven't taken weekends into account, or trips that cross midnight, but first I want to straighten out your definitions.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-03-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Working out a tariff from a date and time

    Hi again 6StringJazzer,

    In terms of how does an arrival link to a departure, they dont.

    each row refers to an individual movement by an aircraft. i.e arr movement, or dep movement.

    I do not need to link each arr movement and dep movement to make a turnaround I simply need to count how many individual times it occurs during a peak period and a non peak period.

    ideally I would like to be able to get an output that tells me:

    Month / Count of Peak / Count of Off-Peak.
    ...
    Jan / 240 / 350
    Feb / 210 / 300 and so on.

    please let me know if this is more clear?

    Thanks

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: Working out a tariff from a date and time

    That is clearer, see attached. Results are on sheet Counts.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-03-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Working out a tariff from a date and time

    Many thanks 6StringJazzer that works great for calculating the peaks and off-peaks, although I have one more thing I hope you can help with.

    A flight is only peak if it operates on a Monday to Friday. if it takes place on Saturday it is off peak.

    Is there a way we can use WEEKNUM in the countif somehow to include this?

    Thanks for all your help so far!

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Working out a tariff from a date and time

    You can't do that with COUNTIFS (not without a helper column at least) - here's a different method using SUMPRODUCT

    Put a zero in sheet3 D1 (you can format as ;;; if you want to hide) and then use this formula in Counts sheet B2

    =SUMPRODUCT((TEXT(Sheet3!A$2:A$1000,"mmm-yy")=TEXT(A2,"mmm-yy"))*(WEEKDAY(Sheet3!A$2:A$1000,2)<6)*(MOD(MATCH(Sheet3!B$2:B$1000,Sheet3!D$1:D$5),2)=0))

    That will work for up to 1000 rows of data, increase if necessary

    in D2 copied down use this formula

    =COUNTIFS(Sheet3!A$2:A$1000,">="&A2,Sheet3!A$2:A$1000,"<="&EOMONTH(A2,0))-B2

    see attached
    Attached Files Attached Files
    Audere est facere

  9. #9
    Registered User
    Join Date
    11-03-2011
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Working out a tariff from a date and time

    Hi Daddylonglegs,

    Firstly this is great, many thanks!

    I was wondering if you could assist if I was to add a few more variables in there?

    Please see the attached.

    I have added airlines and also tariff B/tariff C - both of these are included on each row.

    If you review the 'Counts' sheet you will see there are some cells highlighted red which I am struggling to calculate.

    Many thanks in advance.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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