+ Reply to Thread
Results 1 to 11 of 11

Count how many times a sequence of characters occurs in a column.

  1. #1
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Count how many times a sequence of characters occurs in a column.

    Good day!
    I am trying to determine a tennis player's tie-break record (7-6 or 6-7) set score.
    In the G column we have the scoreline for that respective match.
    The rules are as follows:
    If the value in the L column is positive (2-0, 2-1), then 7-6 means a WON tiebreak, and 6-7 means a LOST tie break
    however
    If the value in the L column is negative (0-2, 1-2), then 7-6 means a LOST tie break and 6-7 means a WON tiebreak

    To determine if the L column is positive or negative, I am using this formula, there are many other ways but:
    LEFT(L2,1)>RIGHT(L2,1)

    The result that I need, is how many tie breaks (7-6, 6-7) were won and how many lost.
    Probably a helper column is needed.
    Have fun solving!
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count how many times a sequence of characters occurs in a column.

    Hi,

    You would of course simplify the whole thing if you had three columns, one for each set. Then a simple COUNTIF() function would work, as indeed would a Pivot Table, which might be OTT but is another option.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Count how many times a sequence of characters occurs in a column.

    Thanks for your suggestion, a column for each set would make it simple enough for me to get it done myself
    I would need 5 columns though as some mens' matches are best of 5.
    Slightly off topic, I even came up with this formula to determine the winner of each set, and it took me a whole day. Would have gotten it done in an hour if I only used a helper column for each set :D
    Please Login or Register  to view this content.
    Last edited by bibu; 07-17-2014 at 05:29 PM.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Count how many times a sequence of characters occurs in a column.

    Here's one that uses a couple of helper columns:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by protonLeah; 07-18-2014 at 01:31 AM.
    Ben Van Johnson

  5. #5
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Count how many times a sequence of characters occurs in a column.

    Thanks for your solution, I am not familiar with the CHOOSE function I am trying to understand how it works. I have made a mistake though, the sample I gave was not representative as there can be best of 5 matches in mens' tournaments, where the L column (set score) value can be 3-0, 3-1, 3-2(for wins) or 0-3, 1-3, 2-3 (for losses)
    Also there can be a case where a player will retire after playing a tiebreak, so the tie break is played but the L column is empty as there is no "set score" to be recorded for that match

    So instead of using the L column, the safest choice would be to use this rule:
    If A2=Q1 then 7-6 will be a won TB, and 6-7 will be a lost TB
    If B2=Q1 then 7-6 will be a lost TB, and 6-7 will be a won TB
    This is because the winner of the match is always in the A column, and the loser is in the B column
    Attached Files Attached Files
    Last edited by bibu; 07-18-2014 at 03:29 AM.

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Count how many times a sequence of characters occurs in a column.

    find the attached file
    hope it will help you
    Attached Files Attached Files
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  7. #7
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Count how many times a sequence of characters occurs in a column.

    I'm sorry, the results are wrong, it shows no lost tie-breaks. For example the 6-7 in G2 is a lost tiebreak.
    For reasons stated in my previous post, the best option would be to not use the L column to determine tiebreak outcome, but rather the
    If Q1=A2 then 7-6 will be a won TB, and 6-7 will be a lost TB
    If Q1=B2 then 7-6 will be a lost TB, and 6-7 will be a won TB
    rule. Q1 = Ana Konjuh
    Also, there is no need for displaying how many were won 6-7 or 7-6, just the total amount of won and lost tie breaks.
    Thanks!

  8. #8
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Count how many times a sequence of characters occurs in a column.

    see the attached file
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Count how many times a sequence of characters occurs in a column.

    This is close to right. I have done the calculation manually and I have counted 5 won and 7 lost as opposed to 5 and 6.
    I think the issue is the 28th row where there are 2 lost tiebreaks and I think your formula only counts 1.
    Keep in mind that there can be 5 possible tie breaks in a G cell (example 6-7 6-7 7-6 7-6 7-6), and all must be counted.
    Attached Files Attached Files

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Count how many times a sequence of characters occurs in a column.

    see the attachment
    i hope it will solve your problem
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    08-04-2013
    Location
    Bucharest
    MS-Off Ver
    Office Professional Plus 2019
    Posts
    303

    Re: Count how many times a sequence of characters occurs in a column.

    It did. There was a small mistake but I was able to correct it myself.
    Instead of starting from 1,5,9,14,19, it should have been 1,5,9,13,17, otherwise the 4th and 5th sets would have not been counted. So, this is solved and thanks a lot for your time and patience.
    Last edited by bibu; 07-18-2014 at 06:15 AM.

+ 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. Count how many times a negative number occurs
    By basalisbury in forum Excel General
    Replies: 6
    Last Post: 04-05-2012, 10:29 AM
  2. Count how many times a letter occurs
    By GreenMartian in forum Excel General
    Replies: 2
    Last Post: 03-15-2009, 04:30 AM
  3. I would like to count the # of times a value occurs in Col B base
    By shopaholic in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-09-2005, 12:30 PM
  4. [SOLVED] How to count the number of times something occurs within a certain month
    By Joyce in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-18-2005, 02:05 PM
  5. Replies: 3
    Last Post: 02-03-2005, 06:06 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