+ Reply to Thread
Results 1 to 12 of 12

Counting True Statements

  1. #1
    Registered User
    Join Date
    05-05-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Counting True Statements

    Hi,

    I've collected some GPS data of an athlete running and want to quantify both the number and duration of individual sprints.

    In the attached xls file, there is a column for time, speed and another that returns whether the speed column is >18 kph or not. False is <18, sprint if >18 kph.

    Each entry with a "sprint" means they are sprinting (running above 18 kph) and each entry is 0.2-s. Thus 5 entries added together = 1-s.

    I want to know, not the total number of sprint entries but the number of sprint groupings for example.

    false, false, sprint, sprint, sprint, false, false,false,false, sprint, sprint, false = two seperate groups of "sprints". I would therefore conclude that the athlete sprinted twice.

    I also want to know the duration of the sprint for each of the groupings. For example based upon each entry being 0.2-s, the first sprint grouping would total 0.6-s and the second grouping 0.4-s.

    Any help would be much appreciated,

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Counting True Statements

    Here's a formulaic approach. In D2 add this:

    =IF(C2="sprint",IF(C3="false",A2,IF(C1="sprint",D1,A2)),"")

    ...and E2 add this:
    =IF(D1="","",IF(N(D2)>N(D1),D2-D1,""))

    Then copy those two formulas down. The start and ending times for sprints will appear in column D and the durations in column E.Attachment 43005
    Last edited by JBeaucaire; 05-07-2009 at 05:20 AM. Reason: Sheet removed...see below for latest version
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Counting True Statements

    Here's another approach.
    Unhide columns D and E to see the intermediate results.
    modytrane
    Attached Files Attached Files

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting True Statements

    and another
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    05-05-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Counting True Statements

    Hi everyone,

    Thanks for your replies, they're all great!

    Cheers

  6. #6
    Registered User
    Join Date
    05-05-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Counting True Statements

    Hi modytrane,

    I've tried to modify the formula to take into account all the data ie. up to 15003 by replacing E$1:E$2000 with E$1:E$15003 but it's just coming up with VALUE in column F!

    Could you help please?

    Thanks in advance

    (I havn't attached the file beacuse its a massive 3mb!)
    Last edited by SportsScientist; 05-06-2009 at 12:08 PM.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Counting True Statements

    The formulas in Col G are array formulas and need to be entered with CNTRL SHIFT ENTER rather than a simple ENTER. Did you do that?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Counting True Statements

    Rethought my approach after looking at the other formulas suggested and I realized only one key column is required and no array formulas at all. Simple MAX() and COUNTIF() formulas. Now only column D is doing the key work:

    D3 copied down:
    =IF(C3="FALSE","",IF(D2="",MAX($D$2:D2)+1,D2))

    SPRINTS in G2 and copied down:
    =IF(MAX(D:D)<ROW()-1,"",ROW()-1)

    DURATIONS in H2 and copied down:
    =IF(G2="","",COUNTIF(D:D,G2)*0.2)
    Last edited by JBeaucaire; 05-07-2009 at 05:20 AM. Reason: Sheet removed...see below for latest version

  9. #9
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: Counting True Statements

    nice solution, JB.
    modytrane

  10. #10
    Registered User
    Join Date
    05-05-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Counting True Statements

    Fantastic! Thanks for all your help.

    I'm way out of my depth here so I need to ask two more questions.

    1. How could I calculate the total distance covered during each sprint?

    (Column C calculates the distance in (m) covered over 0.2-s for each entry)


    2. How could I calculate the time between the sprints?

    Again, any help would be much appreciated,

    Thanks for all your help so far.
    Attached Files Attached Files

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting True Statements

    ive no idea why you used 0.2 in that formula
    total distance in each sprint can be calculated by
    =SUMIF(E:E,H2,C:C) e:e is the column containing 1,2,3,4.....
    where H2 is the one you want to refer to and c:c is where the distances you want to sum are.
    and between sprints just use a modified version of formula in col e to number the falses! see attached
    Attached Files Attached Files
    Last edited by martindwilson; 05-07-2009 at 05:32 AM.

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Counting True Statements

    This adds a simple SUMIF() formula:

    =IF(H2="","",SUMIF(E:E,H2,C:C))
    Attached Files Attached Files
    Last edited by JBeaucaire; 05-07-2009 at 05:22 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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