+ Reply to Thread
Results 1 to 12 of 12

index (count? sequence?) unique dates based on values in another column

  1. #1
    Registered User
    Join Date
    11-03-2011
    Location
    San Francisco
    MS-Off Ver
    Excel 2007
    Posts
    6

    index (count? sequence?) unique dates based on values in another column

    I have 34,545 rows of date information related to 522 products. I want to add a column that shows the week number for each row, starting from the earliest date associated with each product, through the last date. Some rows have the same date for a single product.
    So I need to transform this:
    Product Sell Date Week of Campaign
    Widget A 09-Apr-2011
    Widget C 07-May-2011
    Widget A 16-Apr-2011
    Widget C 30-Apr-2011
    Widget B 16-Apr-2011
    Widget B 14-May-2011
    Widget C 14-May-2011
    Widget B 30-Apr-2011
    Widget A 16-Apr-2011
    Widget A 07-May-2011
    Widget B 23-Apr-2011
    Widget B 16-Apr-2011
    Widget B 07-May-2011
    Widget A 16-Apr-2011
    Widget B 14-May-2011
    Widget C 07-May-2011
    Widget A 23-Apr-2011
    Widget B 09-Apr-2011
    Widget A 30-Apr-2011

    Into this:

    Product Sell Date Week of Campaign
    Widget A 09-Apr-2011 1
    Widget A 16-Apr-2011 2
    Widget A 16-Apr-2011 2
    Widget A 16-Apr-2011 2
    Widget A 23-Apr-2011 3
    Widget A 30-Apr-2011 4
    Widget A 07-May-2011 5
    Widget B 09-Apr-2011 1
    Widget B 16-Apr-2011 2
    Widget B 16-Apr-2011 2
    Widget B 23-Apr-2011 3
    Widget B 30-Apr-2011 4
    Widget B 07-May-2011 5
    Widget B 14-May-2011 6
    Widget B 14-May-2011 6
    Widget C 30-Apr-2011 1
    Widget C 07-May-2011 2
    Widget C 07-May-2011 2
    Widget C 14-May-2011 3

    I really appreciate any help, even reference to a formula name.
    Thanks!
    --William
    Attached Files Attached Files
    Last edited by William Judd; 11-04-2011 at 01:02 PM. Reason: Solved

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

    Re: Newbie: index (count? sequence?) unique dates based on values in another column

    Your post belongs in one of the Help Request forums, however...
    Does this work?
    Attached Files Attached Files
    Ben Van Johnson

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Newbie: index (count? sequence?) unique dates based on values in another column

    If this is a one off exercise, go with protonLeah.

    If the workbook is constantly updated then this might help.

    This workbook uses non-volatile dynamic named ranges, this might cause your actual workbook (34k+ rows) to take longer to open, but once opened it will greatly out perform volatile names.
    The helper column that concatenates Columns A&B, then removes duplicates, is hidden with the grouping button

    Add to Columns A:C as required, keep the data in Column A continuous i.e. no blanks.

    Note
    Some of your dates have times included this could lead to inconsistancies in the returned values, hence the use of INT() in the formulae.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Registered User
    Join Date
    11-03-2011
    Location
    San Francisco
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: index (count? sequence?) unique dates based on values in another column

    Thank you, protonLeah. I appreciate your quick assistance very much! I see now that my original request was badly worded (in addition to being posted in the wrong place!).
    What I need is not the "Week Number" counted from Jan 1, but the week number counted from the first instance of each widget. Marcol's suggestion does the same thing, thanks to my misleading request. So sorry about that.

    For each record that belongs to widget A, I want to check the date to know if that record belongs to the first week of the campaign, the second week of the campaign, and so on. 552 campaigns, each with its own start date and each with some number of records between 2 and about 100.

    I really really appreciate your efforts!
    --William

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

    Re: Newbie: index (count? sequence?) unique dates based on values in another column

    Thank you, Marcol. Sorry about my misleading original request (and it was posted in the wrong place!).

    What I need is not the "Week Number" counted from Jan 1, but the week number counted from the first instance of each widget.

    For each record that belongs to widget A, I want to check the date to know if that record belongs to the first week of the campaign, the second week of the campaign, and so on. 552 campaigns, each with its own start date and each with some number of records between 2 and about 100.

    I so very much appreciate your efforts!
    --William

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,275

    Re: index (count? sequence?) unique dates based on values in another column

    Try this code...
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-03-2011
    Location
    San Francisco
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: index (count? sequence?) unique dates based on values in another column

    Like magic! Thank you very much - it is awesome.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: index (count? sequence?) unique dates based on values in another column

    See if Sheet2 of this workbook might be a formula solution.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-03-2011
    Location
    San Francisco
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: index (count? sequence?) unique dates based on values in another column

    Thank you, sir. This combination of formulae approaches what I need and is indeed nifty. But I need to use the new column "campaign week #" alongside the original data in order to generate more reports/piviots. So I can't use a solution that summarizes the data. For each and every original row, I need one ordinal "campaign week #" even if there are duplicates.

    Is there a formulaic method for that?

    Cheers,
    --William

  10. #10
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,275

    Re: index (count? sequence?) unique dates based on values in another column

    You are welcome!

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

    Re: index (count? sequence?) unique dates based on values in another column

    assuming you sort your data so that it is sorted by column A then by column B (oldest to newest) then you can use this formula in C2 copied down to get the week number

    =INT((INT(B2)-INT(VLOOKUP(A2,A:B,2,0)))/7+1)

    see attached
    Attached Files Attached Files
    Audere est facere

  12. #12
    Registered User
    Join Date
    11-03-2011
    Location
    San Francisco
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: index (count? sequence?) unique dates based on values in another column

    Thank you Daddy Longlegs! Spiffing. Thank you for listening and making (hope my Latin's not too rusty there).
    One more operation I want to perform is to identify the first date and last date of each campaign. This could result in a list of the 522 unique campaigns with their start and end dates. I haven't been able to figure out a formula that will do that, though.
    Cheers,
    --William

+ 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