+ Reply to Thread
Results 1 to 5 of 5

How to count number of times a value in a chart switches column?

  1. #1
    Registered User
    Join Date
    01-30-2020
    Location
    Vancouver, Canada
    MS-Off Ver
    Version 1808
    Posts
    3

    How to count number of times a value in a chart switches column?

    I am not very experienced with excel, so I would appreciate any advice about how to proceed with a task I am trying to complete. I have attached a sample of the data I am working with - essentially it is a record of an animal's location and body position every minute for a period of several hours. The data was collected using a 1-0 sampling method, so a 1 in a cell indicates she is in that location or body position and a 0 indicates that she is not.

    I am trying to quantify the activity level of the animal by counting every time she switches location or body position. However, if she switches location and body position at the same time, I want this to count as 1, not 2.

    I am at a loss about how to do this other than counting the number of times each column changes from 1 to 0 or 0 to 1 and manually comparing every column to eliminate overlapping counts - any advice about how to proceed would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,938

    Re: How to count number of times a value in a chart switches column?

    I'd add 2 helper columns to be used as condition for each set. Then another column for tallying up if each period met the condition or not.

    However, how do you intend on handling "NA" for each set? Does NA mean that observation wasn't made?

    Do you count as switching column if it changed from Lying to NA or vice versa?
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Registered User
    Join Date
    01-30-2020
    Location
    Vancouver, Canada
    MS-Off Ver
    Version 1808
    Posts
    3

    Re: How to count number of times a value in a chart switches column?

    Thank you for your help! The NA means that the animal was not visible for an observation to be made - that is a good point you bring up, I should delete the NA column.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,938

    Re: How to count number of times a value in a chart switches column?

    Ok then. For now I excluded NA columns.

    Here's brief set up:
    1. AE3: =IFERROR(MATCH(1,$F3:$V3,0),AE2)
    Copy down.

    2. AF3: =IFERROR(MATCH(1,$Y3:$AB3,0),AF2)
    Copy down.

    IFERROR is used to carry over, previous period's observation if all columns return 0 (i.e. NA is 1).

    Then in AG3:
    =IF(ROWS($A$1:$A3)=3,0,--((($AE2<>$AE3)+($AF2<>$AF3))>0))
    Copy down.

    Basically this checks if either AE/AF changed from previous row. If yes, return 1, if no, return 0. First if argument is just there to check for first observation (i.e. not a change so 0).

    See attached.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-30-2020
    Location
    Vancouver, Canada
    MS-Off Ver
    Version 1808
    Posts
    3

    Re: How to count number of times a value in a chart switches column?

    Thank you very much for your help!

+ 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: 1
    Last Post: 02-19-2014, 10:12 PM
  2. [SOLVED] Count number of times names appear in a column
    By jeremysayshi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-06-2014, 01:24 PM
  3. Count number of times when data is highest among a column
    By arrontan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-20-2013, 06:10 AM
  4. [SOLVED] count the number of times each string appears in a column and make a summary column
    By intothewild in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2012, 08:02 AM
  5. Help with using VBA to count number of times different values appear in a column
    By compto in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2012, 12:47 PM
  6. [SOLVED] Count number of times of name appears in a column
    By Ness78 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 08-01-2012, 08:14 AM
  7. [SOLVED] How to count the number of times column B is greater than column A
    By scorpiogirl in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-06-2012, 02:40 AM
  8. How to count the number of times a string appears in a column?
    By btsray in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2006, 06:55 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