+ Reply to Thread
Results 1 to 15 of 15

Formula for running total (static count) of repeated values in a table

  1. #1
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Formula for running total (static count) of repeated values in a table

    I have a table where data is entered on the next empty row. In one column, 'D', is a numeric value (an ID number). I need a static count, running total of how many times that number appears as data is added. So the first time "123" appears, for example in D2, the formula in E2 will return and stay at '1'. The next time it appears, whether that's on the next row or several rows down, say in E6, the forumla in E6 would say '2' but the formula in E2 will remain at '1.'

    I have a header row, so in my first row of data, in E2, I have =COUNTIF($D$2:D2, D2).

    If all me data was already entered, I could copy this down and it would work fine... but when I go to add the next row, row 3, Excel automatically changed the formula in E2 to =COUNTIF($D$2:D3,D2) and my count was incorrect.

    My current formula also seem susceptible to being incorrect if a row of data in the middle of the table needs deleted. Can't use VBA for this - has to be a formula.

  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,721

    Re: Formula for running total (static count) of repeated values in a table

    Quote Originally Posted by HeyInKy View Post
    [...]when I go to add the next row, row 3, Excel automatically changed the formula in E2 to =COUNTIF($D$2:D3,D2) and my count was incorrect.
    This should not be happening. How are you adding the next row, row 3? Are you simply entering more data in the next row, or are you inserting a row? Adding a row, even inserting a row, after row 2 should not affect the formula in row 2.

    I suggest you attach your actual file, and explain how you are adding new data (just entering data, or inserting rows?). You also mention deleting rows; explain the scenario where you would delete a row so we can reproduce it.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor Mvaldesi's Avatar
    Join Date
    01-21-2011
    Location
    Plano, TX
    MS-Off Ver
    MS365 (PC) v.2108
    Posts
    259

    Re: Formula for running total (static count) of repeated values in a table

    I dunno; your formula works for me unless I'm not understanding your intentions correctly?
    Attached Files Attached Files

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    By any chance... do you have calculation options set to manual, instead of automatic???
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: Formula for running total (static count) of repeated values in a table

    @Glenn Kennedy - it appeared it did, but when I removed it, it's still acting peculiar.

    @6StringJazzer see below... try entering the value in E2 into E3, and see if F2 and F3 work. Thanks!

    Sample WB A.xlsx

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    The countif in F is looking at column D. If you add something in column E and add nothing in column D, then the result of the countif WILL NOT CHANGE, until you add a value in column D... at which point, it works perfectly.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    I do not see the point in referring the countif to column D, since the data validation in that column requires it to be a previously unused number, so the results of the countif will always be 1....

  8. #8
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: Formula for running total (static count) of repeated values in a table

    My post said D for values and E for formulas - by my workbook actually used columns D (Interview ID) and column F (No. of Cases)...

    And the data validation should be just to ensure 7 digits...

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    The DV Message reads:

    The Interview ID must be 7 numeric digits and cannot be one previously entered.

    But there is, admittedly, nothing in the formula to prevent duplication.

    However, I still do not understand why you expect the formula:

    =COUNTIF(D$2:D2,D2)

    to change the result produced when you add a value to E and add NOTHING to D!!! Please explain....

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    I think I have (finally) been able to reproduce your problem. First check the formulas in F. They're fine. Select the last two franlins and drag down two rows. The formulae at teh foot of the table are all messed up. They are not in an orderly sequence.

    I have seen this before... but cannot remember..
    Attached Files Attached Files

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    Try this in F2:

    =COUNTIF(INDEX([Interview ID],1):[@[Interview ID]],[@[Interview ID]])

    It seems to be OK... but this one has done my head in....

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

    Re: Formula for running total (static count) of repeated values in a table

    Formula for E2

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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.

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    That doesn't work, if he's going to drag Franklin down....

    see yellow cells.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    Re: Formula for running total (static count) of repeated values in a table

    @Glenn Kennedy

    The file you uploaded works, but I think the formula you posted with the absolute table references is very stable! I was actually close to something similar, but my syntax was off.... a big thanks for your help!

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Formula for running total (static count) of repeated values in a table

    You're welcome. It did have me baffled, for quite a while....



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. Replies: 3
    Last Post: 06-12-2013, 10:53 PM
  2. Replies: 4
    Last Post: 06-12-2013, 12:51 PM
  3. Replies: 3
    Last Post: 05-08-2013, 07:25 AM
  4. Excel 2007 Pivot Table help required to total columns repeated month
    By wendy19804 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-04-2011, 11:39 AM
  5. Count repeated vaule and total sum
    By dpatel in forum Excel General
    Replies: 5
    Last Post: 08-05-2010, 09:35 AM
  6. Count of repeated values
    By sagar in forum Excel General
    Replies: 3
    Last Post: 03-28-2007, 03:49 AM
  7. [SOLVED] % of Running Total to Grand Total in Pivot Table
    By David in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2005, 04: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