+ Reply to Thread
Results 1 to 8 of 8

Counting Occurrences

  1. #1
    Registered User
    Join Date
    07-28-2015
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    4

    Question Counting Occurrences

    Hi,

    I have a set of temperature data that I need to analyse and determine the number of excursions above a certain temperature.
    The problem is my data is in 2 minute intervals and I do not want to count consecutive excursions separately but rather as a single excursion. For example:

    1.JPG

    If I use the countif function it counts the number of times a temperature is above the certain limit, in this case 550 as seen in row 16. However I want it to count the number of times the temperature exceeded the limit but returned to below the limit, as seen in row 17.

    Hope someone will be able to assist me.

    Thanks,
    RiaanDeysel
    Last edited by RiaanDeysel; 07-28-2015 at 08:57 AM.

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Counting Occurrences

    pivot table.
    record a macro to run it and count Col C.
    run it after you update the data.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Counting Occurrences

    How do you get the result of 14? There are 6 values >550.

    It looks like you want to count consecutive cells that are >550 as a single instance based on the results in column C.

    If that's the case try this array formula**:

    =SUM(IF(FREQUENCY(IF(B2:B15>550,ROW(B2:B15)),IF(B2:B15<=550,ROW(B2:B15)))>1,1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    07-28-2015
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting Occurrences

    Hi Tony,

    Sorry I only saw that mistake after you mentioned it, looks like I used count and not countif for that example.

    Thanks for the advise will definitely try the array formula and give feedback if it works.

  5. #5
    Registered User
    Join Date
    07-28-2015
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting Occurrences

    Tony,

    So I have tried using your array formula and it seems to be working. However, it only counts occurrences if there are two or more consecutive cells >550 but not single cells >550
    I changed some of the values to show more excursions for the example:

    2.JPG

    Any advice?
    Attached Images Attached Images
    Last edited by RiaanDeysel; 07-28-2015 at 09:53 AM.

  6. #6
    Registered User
    Join Date
    10-23-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Counting Occurrences

    Ok, this is the first time i post an answer, so please bear over with me if I do not follow the correct procedure, but I have checked the rules and hope I comply

    You can use this macro:

    Please Login or Register  to view this content.
    This will return the number 6 in cell C16 and the number 2 in C17.

    Another way without using Macro's:
    Insert this formula in all 14 lines in column C (C2:C15) with cell C2 as the example here:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    And in all cells in column D starting with D3 (D3:D15) you insert this with cell D3 as the example hereunder:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In cell C16 you then write:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    And in C17:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This will give you the same result as the Macro above.

    Hope this will work for you.

    BR
    Ipsenh
    (A.K.A. Excelipsen)

  7. #7
    Registered User
    Join Date
    07-28-2015
    Location
    South Africa
    MS-Off Ver
    2010
    Posts
    4

    Re: Counting Occurrences

    Hi Ipsenh,

    Simple and easy, thank you it works!

    Regards,
    RiaanDeysel

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Counting Occurrences

    I based the formula on the data and expected results in the first post.

    If you want to count every streak as a single instance then use this version:

    =SUM(IF(FREQUENCY(IF(B2:B15>550,ROW(B2:B15)),IF(B2:B15<=550,ROW(B2:B15))),1))

    Still array entered.

+ 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] counting occurrences
    By kri54sub in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-11-2013, 01:01 PM
  2. Counting occurrences within each month
    By Fatosi in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-14-2012, 04:26 PM
  3. Counting occurrences
    By HaydenB in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 10-30-2010, 04:26 PM
  4. Counting occurrences of text
    By pinkgoldfish in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-27-2007, 04:48 AM
  5. Counting number occurrences
    By thermometer in forum Excel General
    Replies: 3
    Last Post: 06-06-2006, 03:10 PM
  6. Counting number of occurrences
    By LyleB_Austin in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-15-2005, 06:05 PM
  7. [SOLVED] counting occurrences in a range
    By Judy Felfe in forum Excel General
    Replies: 3
    Last Post: 07-20-2005, 04:05 PM
  8. counting the most consecutive occurrences
    By Reignman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-12-2005, 05:56 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