+ Reply to Thread
Results 1 to 30 of 30

Non-Consecutive Count

  1. #1
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Non-Consecutive Count

    Hello all, I have a bit of a difficult one here, help will be appreciated. Essentially:



    I want to use a formula to count strings on a specific value as 1 entry till either supply comes or another interruption takes place. (Strings can be EF, OC, SG, SS, IMB, NS, BF, RF etc)

    EG: The example below if done right with the formula would count (LS as 2); (NS as 2); (EF as 2) and SG as 1.

    LS
    LS
    LS
    2.4
    2.5
    NS
    NS
    EF
    NS
    3
    EF
    EF
    LS
    SG


    Also note if the last hour of the previous day of a certain feeder is the same as the first hour on the present day, present day does not get counted.


    EG

    Previous day grid model Current day grid model
    21:00 ef ns
    22:00 ns imb
    23:00 ns ns
    24:00 ns oc


    So here on the current day, you would see a count for (NS as 1) (IMB as 1) (OC as 1)

    To further emphasize, I have attached 2 snips of each sheet, the conditionally formatted document is the source and (interruption) numbers. The values on interruption are all correct. Sars rd, adp, market, igwu, aka, ibb, indon and udo udoma all ended in ss on the previous day hence the missing value count for each of these.
    Attached Images Attached Images

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,113

    Re: Non-Consecutive Count

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Okay thanks for clarifying. The sample workbook is now attached.
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,113

    Re: Non-Consecutive Count

    Sorry - I have no clue what you are trying to do or where - can you please tell us where we will find the results that you have mocked up manually to show what you want?

  5. #5
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Okay,

    So the sample workbook contains 3 sheets, 30th, 1st and Interruption. I am trying to use the 1st of December to populate the interruption sheet. The 30th is included to show continuity between two days.

    For example cell A29 on the 30th continues on to A6 of the 1st hence, the cells (A6: A9) with SS values will not be counted on the interruption sheet.

    The formula when created will count the following for row 6 (Sars rd) of the interruption sheet

    EF BF RF DC IMB OC EMG LS SG LSG NS SS

    2 1 1 ( For LS, NS, SS respectively)

    Rows 3, 4 and 5 on the interruption workbook can be ignored


    The point is to count any continuous string of consecutive values as 1 entry. Take a look at column f on the workbook (pipeline)

    PIPE LINE
    2.0
    LS
    LS
    LS
    1 count of LS
    2.4
    2.6
    2.5
    EF
    EF
    EF
    1 count of EF
    NS
    NS
    NS
    NS
    NS 1 count of NS
    NS
    NS
    NS

    SS 1 count of SS
    3.3
    3.2
    3.0
    2.8
    2.7
    Last edited by yukibare; 12-11-2020 at 08:08 AM.

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Non-Consecutive Count

    Maybe others can do better but I am not sure what you are asking. what value wants to appear in what cell on what sheet and the reason/logic for this?


    Are you wanting to count the number of runs of each of the numbers listed? Or just that they had appears at all

    =COUNTIFS(J5:J28,"<>LS",J6:J29,"LS") will count 3 as there are 3 runs of LS

    but your interruption sheet is transposed which makes the formulas far more painful, especially as you have not called things by the same name to match. Sars rd and sars road for example. do the sheets have to be transposed?

  7. #7
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Hello Davsth,

    Thanks for responding. Firstly the heading names are irrelevant, they do not need transposing; what we are trying to do is count the number of interruptions to power supply for various types of fault occurences.

    The LS count you're referring to, if its for the pipeline example, has to be counted as 1 (for the 3 runs as you put it) as it is 1 interruption to the power supplied.

    So if ns (no supply) appears for 3 consecutive hours, that amounts to 1 interruption for ns.

    I hope this has answered your question?

  8. #8
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    more information:

    LS - load shedding
    NS - No supply
    BF - Breaker fault
    EF - Earth fault
    OC - Over current
    SS - Station under service


    This is a sample load consumption grid model for a distribution company in western africa

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

    Re: Non-Consecutive Count

    I think I understand.

    Three Qs.

    1. Do you REALLY need the raw data on two sheets? It would be much easier if they were on one sheet, with an additional column for the date.

    2. Where are these on your raw data?
    ALUU
    CHOBA
    RUMUEKINI


    3. WHY have you broken the logical sequence of your data with a total column in the raw data sheets, column K and in the results sheet, row 16? These interuptions are an Excel nightmare and should be avoided. Logical layout is KING.
    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

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

    Re: Non-Consecutive Count

    Another Q. It there is an LS as the last entry for the day in one place, and an LS as the first entry for the NEXT day in the SAME place, is that 1 interruption, or two?

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

    Re: Non-Consecutive Count

    Yukibare, you have logged off. So... I combined the days into one sheet, ignored the 3 missing locations, and removed the columns/rows interrupting the logical data layout. I also assumed that last on day 1 / first on day 2 combination counts as 1 interruption. So:

    =SUMPRODUCT((INDEX(Raw!$B$6:$Q$53,,MATCH($A6,Raw!$B$5:$Q$5,0))=E$2)*(INDEX(Raw!$B$7:$Q$54,,MATCH($A6,Raw!$B$5:$Q$5,0))<>E$2))

    copied across and down.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Alright Glen,

    1) Feel free to copy/paste on one sheet, I can link them later. This is operating procedure that I can't break haha.

    2) These three from the interruption sheet are to be ignored as I added them accidentally to the sample workbook

    3) They broke as I had to unlink the original data source, excel nightmare indeed pal; however, for the purposes of this formula they are unnecessary.

    4) For the NEXT day, it would NOT count as an interruption as between midnight and 1am, the no power supply stays the same. The interruption would only count if say previous day ends in NS and current day starts in LS. The count is done only on current day using previous as a reference IF there is an interruption on the first data value at any given location.

    5) Noticed you on quite a few forums, glad to have a maestro keyed in to my problem.

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

    Re: Non-Consecutive Count

    LoL. So take a look at the file. It should do what you want. IF it does, I need to make some minor changes, to allow the ranges of the formula to adjust automatically when you add more days data. At the moment, that has to be done manually, which is a bit of a pain.

  14. #14
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Right I've had a look at your workbook Glen and its close to perfect.

    I can handle changing the formula to reflect a one day count (1st december) however, the interruption shouldn't be counted if it spills over into the next day which it is.

    The only reason I've attached 2 days is to reflect a non count on the 1st dec if the 30th nov has the same value at midnight. I tried changing your formula to reflect this and it didn't work out.

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

    Re: Non-Consecutive Count

    I am unclear about what you mean;
    the interruption shouldn't be counted if it spills over into the next day

    Mon EF
    Mon LS
    Mon LS
    Mon LS
    Tue LS
    Tue LS
    Tue EF

    is this ONE interruption or two?

  16. #16
    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,099

    Re: Non-Consecutive Count

    Badly worded Question... Is this one LS interruption, or two?

  17. #17
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Yessir, it does what I want it to do. Automating would be great.

    The minor change would be counting from B30 instead of B6 in order to start the count from the 1st dec and the non count of spillage from previous day to next. Thank you so much

  18. #18
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    okay so for tuesday there would be no Ls interruption unless one occurs below EF. Interruptions happen when, you know, something interrupts. So essentially from the data you posted just now, the only count would be EF for tuesday

  19. #19
    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,099

    Re: Non-Consecutive Count

    OK. Next area that I don't understand. My sheet calculates a TOTAL number of interruptions, by type, by location. So, 30/11 and 1/12 are combined. Is that NOT what you want. If not, what DO you want?

  20. #20
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    I would like for the 30th to be ignored on the count front. The interruptions are counted on a daily basis. Type and location is correct; the 30th Nov data shows which Row 30 values (according to your edited workbook) on the 1st dec should NOT be counted. So essentially the correct answer for sars road on the first of december is (2 1 1) for (LS NS and SS) respectively while yours has 4,4,4 which is the sum of both days.

  21. #21
    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,099

    Re: Non-Consecutive Count

    Can I then add a dropdown on the results sheet to select the day chosen for calculation?

    Then I shall have to think about the day end/day beginning problem again...

  22. #22
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Dropdown if absolutely necessary, The manual nature of this sheet is mind boggling so at this point I would be okay with the automation as long as it works just fine

  23. #23
    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,099

    Re: Non-Consecutive Count

    OK. Dates now in a dropdown in cell A2.

    My last problem is those day-change events. See cell P3: SS on Sars Road. What is the expected result for 30/11/2020 and 01/12/2020? I still don't quite understand the day-change rule....
    Attached Files Attached Files

  24. #24
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Okay so as cell B29 on the Raw is 'SS' then B30:B33 will NOT be counted as SS due to the fact that its a continuous interruption. Essentially, the expected result for P3 is '1' for the first of december as B30:B33 will not be counted.

  25. #25
    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,099

    Re: Non-Consecutive Count

    OK, sir. Over to you. Try to break it....
    Attached Files Attached Files

  26. #26
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Haha, I've spent a good while on it already mate, if you can't crack it I don't think anyone can. Thanks for the help anyway, I'm one step away from the goal because of you.

  27. #27
    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,099

    Re: Non-Consecutive Count

    Well test it hard. I'm away for the night now. It's beer o'clock in Belfast.

    You're welcome.



    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.

  28. #28
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Be sure to buy you a pint next time I'm over there Northern Ireland's got great people... done with the reputation but my problem still persists so can't mark it solved just yet.

  29. #29
    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,099

    Re: Non-Consecutive Count

    What remsins to be done?

  30. #30
    Registered User
    Join Date
    12-11-2020
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    2013
    Posts
    37

    Re: Non-Consecutive Count

    Realised you've done it all, just the format that needs work. Thanks again Glen

+ 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] Count down from the Maximum number in each consecutive count
    By gra0001 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-01-2020, 01:20 AM
  2. Count consecutive > zero, ignore zero count consecutive > zero next cell
    By karl.smith in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-16-2020, 07:58 AM
  3. Replies: 7
    Last Post: 03-09-2020, 07:11 PM
  4. [SOLVED] Count Consecutive & Non consecutive days per given logic
    By asimraza89 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-26-2019, 04:31 PM
  5. [SOLVED] Count number of occurrences but if there are consecutive matches count them as one
    By michaljireht in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-26-2013, 08:26 PM
  6. Count Consecutive #'s
    By ctrapper in forum Excel General
    Replies: 8
    Last Post: 03-12-2010, 10:41 AM
  7. [SOLVED] Count Intervals of 2 Consecutive Values in same Row and Return Count across Row
    By Sam via OfficeKB.com in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-29-2005, 11:30 AM

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