+ Reply to Thread
Results 1 to 4 of 4

Creating a "counter" depending on categorical time series data

  1. #1
    Registered User
    Join Date
    06-17-2019
    Location
    Philadelphia, PA
    MS-Off Ver
    2016
    Posts
    1

    Creating a "counter" depending on categorical time series data

    Hi! I have a large spreadsheet (with about 80000 rows), and each row is one of 2 categories: "Stimulus" or "Blank". These appears as series of about 20-70 "Stimulus" or "Blank" rows in a row, alternating between "Stimulus" and "Blank" series (the length of this series varies throughout the spreadsheet). For reference, 1 "Stimulus" series + 1 "Blank" series of rows = 1 trial. What I'm trying to do is create a function for column that keeps track of the row # within each trial object (i.e. a counter that resets at each "change" from "Stimulus" to "Blank" and vice versa.). E.g. :

    A B
    Stimulus 1
    Stimulus 2
    Stimulus 3
    Stimulus 4
    Blank 1
    Blank 2
    Blank 3
    Blank 4
    Blank 5
    Blank 6
    Stimulus 1
    Stimulus 2
    Stimulus 3
    Blank 1
    Blank 2
    Blank 3
    Blank 4
    ...

    So a sketch of the solution would be this function: =IF(A1=A2, B1 + 1, 1).

    However, the issue with my raw data is that the above data is printed out in every other row (i.e. each row is "double spaced"), and because the file is so large, and I have to do this for multiple files, I've found that filtering out/deleting the empty rows would take far too long to process and require a fair amount of manual labor. How can I adjust this function so that it will do the same "counting" function, but for data printed out in every other row within the spread sheet?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Creating a "counter" depending on categorical time series data

    Hi mj and welcome to the forum,

    I think I understand your problem. You need to remove blank rows and not change the sorting of the rows that aren't blank. I'd suggest learning Power Query that has the ability to remove those blanks and not sort, almost instantaneously.

    See this site for an example.
    https://datachant.com/2016/12/09/rem...l-power-query/

    If you don't have PQ yet, I think you can install it as an Add-In from Microsoft.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    06-18-2019
    Location
    Chile
    MS-Off Ver
    MS OFFICE STANDARD 2013
    Posts
    7

    Re: Creating a "counter" depending on categorical time series data

    What if you prepare your raw data first by using the "Text to Column" option in the Data ribbon?
    This tool has the hability to transform delimited tex into multiples columns. Hope it helps!

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,531

    Re: Creating a "counter" depending on categorical time series data

    Assuming that the first occurrence of the word stimulus is in cell A2 try pasting the following formula into cell B2 and double click the fill handle to copy down: =IF(A2<>A1,1,SUM(B1,1))
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. [SOLVED] Brief formula to convert time values to "shift1", "shift2", "shift3".
    By darekpawel in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 04-11-2019, 07:05 AM
  2. [SOLVED] Conditional formatting "night and day" depending on time period
    By Duncan- in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 05-29-2018, 02:02 PM
  3. Beginner needs help! "Run-time error 438" while attempting to format multiple series
    By elodiePhD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-14-2016, 06:10 AM
  4. [SOLVED] Assign Categories for Time of Day: "Morning", "Afternoon", "Evening"
    By long_shanks in forum Excel General
    Replies: 3
    Last Post: 06-11-2013, 02:59 AM
  5. Replies: 2
    Last Post: 11-01-2012, 04:35 PM
  6. Creating List of 25 "Journal" Entries Depending on data entered
    By tbonesmith66 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2012, 05:08 PM
  7. Run-time error "1004" when changing the name of a series
    By Doctorul in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 04-26-2010, 04:15 AM

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