Hoppa till huvudinnehåll

 Hur räknar man maximalt antal på varandra följande positiva / negativa siffror i Excel?

Om du har en lista med data som blandas med positiva och negativa siffror, och nu vill du räkna det maximala antalet på varandra följande positiva och negativa siffror som följande skärmdump visas, hur kan du hantera den här uppgiften i Excel?

Räkna det maximala antalet på varandra följande positiva och negativa tal med matrisformler


Räkna det maximala antalet på varandra följande positiva och negativa tal med matrisformler

 

 

För att få det maximala antalet positiva och negativa siffror i följd, använd följande matrisformler:

Räkna det maximala antalet positiva siffror i rad:

Ange den här formeln i en cell där du vill få resultatet:

=MAX(FREQUENCY(IF(A2:A20>0,ROW(A2:A20)),IF(A2:A20<=0,ROW(A2:A20)))), och tryck sedan på Ctrl + Skift + Enter tangenter tillsammans, och du får rätt resultat efter behov, se skärmdump:


Räkna det maximala antalet på varandra följande negativa tal:

Ange den här formeln i en cell där du vill få resultatet:

=MAX(FREQUENCY(IF(A2:A20<0,ROW(A2:A20)),IF(A2:A20>=0,ROW(A2:A20)))), och tryck sedan på Ctrl + Skift + Enter samtidigt, och du får resultatet efter behov, se skärmdump:

Anmärkningar: I ovanstående formler, A2: A20 är listan över cellintervall som du vill använda.

 

Bästa kontorsproduktivitetsverktyg

🤖 Kutools AI Aide: Revolutionera dataanalys baserat på: Intelligent utförande   |  Generera kod  |  Skapa anpassade formler  |  Analysera data och generera diagram  |  Anropa Kutools funktioner.
Populära funktioner: Hitta, markera eller identifiera dubbletter   |  Ta bort tomma rader   |  Kombinera kolumner eller celler utan att förlora data   |   Rund utan formel ...
Superuppslag: Flera kriterier VLookup    VLookup med flera värden  |   VSök över flera ark   |   Fuzzy Lookup ....
Avancerad rullgardinslista: Skapa snabbt en rullgardinslista   |  Beroende rullgardinslista   |  Flervals-rullgardinslista ....
Kolumnhanterare: Lägg till ett specifikt antal kolumner  |  Flytta kolumner  |  Växla synlighetsstatus för dolda kolumner  |  Jämför intervall och kolumner ...
Utvalda funktioner: Rutnätsfokus   |  Designvy   |   Stor formelbar    Arbetsbok & Bladhanterare   |  Resursbibliotek (Automatisk text)   |  Datumväljare   |  Kombinera arbetsblad   |  Kryptera/Dekryptera celler    Skicka e-postmeddelanden efter lista   |  Superfilter   |   Specialfilter (filtrera fet/kursiv/genomstruken...) ...
Topp 15 verktygssatser12 text verktyg (lägga till text, Ta bort tecken, ...)   |   50+ Diagram Typer (Gantt Chart, ...)   |   40+ Praktiskt Formler (Beräkna ålder baserat på födelsedag, ...)   |   19 Införande verktyg (Infoga QR-kod, Infoga bild från sökväg, ...)   |   12 Konvertering verktyg (Siffror till ord, Valutaväxling, ...)   |   7 Slå ihop och dela verktyg (Avancerade kombinera rader, Dela celler, ...)   |   ... och mer

Uppgradera dina Excel-färdigheter med Kutools för Excel och upplev effektivitet som aldrig förr. Kutools för Excel erbjuder över 300 avancerade funktioner för att öka produktiviteten och spara tid.  Klicka här för att få den funktion du behöver mest...

Beskrivning


Fliken Office ger ett flikgränssnitt till Office och gör ditt arbete mycket enklare

  • Aktivera flikredigering och läsning i Word, Excel, PowerPoint, Publisher, Access, Visio och Project.
  • Öppna och skapa flera dokument i nya flikar i samma fönster, snarare än i nya fönster.
  • Ökar din produktivitet med 50 % och minskar hundratals musklick för dig varje dag!

 

Comments (20)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
PPPPPPPQQQQPPPPQQPPQQPPPPPP

I have a data like above. I have applied the formula that you have suggested. It was working fine. Answer was 7.

={MAX(FREQUENCY(IF(A4:AA4=P, COLUMN(A4:AA4)),IF(A4:AA4<>P, COLUMN(A4:AA4))))}
But now my requirement is this formula should consider only the last 10 cells from the formula applied cells. and the answer should come as 6.
Is it Possible.
Please suggest a way
This comment was minimized by the moderator on the site
Hi,
This was very useful. Thank You very much !!
A question, what if in the data array I want to ignore blanks or zeros. Like the if the next number after blank or zero is positive it should add in frequency

Thanks for your help
This comment was minimized by the moderator on the site
Hello, Naveen
To solve your problem, please try the below formula:
=MAX(FREQUENCY(IF(A2:A20>=0,ROW(A2:A20)),IF(A2:A20<0,ROW(A2:A20))))

After copying and pasting the formula, please remember to press Ctrl + Shift + Enter keys together to get the correct result.
Please try, hope it can help you!
This comment was minimized by the moderator on the site
안녕하세요. 감사합니다. 데이터 필터된 상황의 경우에도 연속 손실이나 이익 수를 계산할 수 있는지 궁금합니다. 그리고 데이터 필터된 상횡의 평균 연속손실 수를 계산하는 방법은 있습니까?
Rated 5 out of 5
This comment was minimized by the moderator on the site
Wonderful, thank you! I'm using your formula now, but I have a question: Is there any way to further filter the data so that it only counts consecutive positive/negative cells IF they share a value in a different column? For example, if, using your example above, in Column B (next to your Number List in Column A) the cells were filled with either the letter 'A' or 'B' in random order, what formula would you use to determine the max number of positive cells that are ALSO consecutive A's in Column B?
This comment was minimized by the moderator on the site
It's amazing, just wondering if there a way to highlight consecutives?
This comment was minimized by the moderator on the site
I get an #Value output if there are only a streak of positive numbers only. Also, I get the same error, if there is only negative streak of numbers. It works fine when there are at least 1 positive and at least 1 negative number on the column. Does anybody knows how to fix this issue. I am using open office.Which uses the same commands, except for the " ; " instead of " , " as a separator.
This comment was minimized by the moderator on the site
Hello, Pablo,
The formulas work well in my wotksheet when there are a list of positive or negative numbers, do you press Ctrl + Shift + Enter keys together to get the result?
This comment was minimized by the moderator on the site
Hello,
Tank you for this post.I'm trying to get the average number of consecutive negative number from a row.I've been trying to do it myself but I can't figure it out.
Would you mind helping me ?
Thanks !
This comment was minimized by the moderator on the site
So, usefull context. I was jus making a video for my Youtube Channel. When i googeled some key word, i came across with your formula. First of all, thank you. And secondly i will give reference to this website for the formulas explanation. I have not so many subscriber, but it may give your website a littele bit more traffic. Thank you and have nice day.
This comment was minimized by the moderator on the site
Hi, thank you very much for the information! It's very useful :) I wondering if is posible to add up the Max Number of consecutive negatives? I will apreciate a lot if you can help me. Thank you!!
This comment was minimized by the moderator on the site
Hi, Joan,
To solve your problem, please do with the following array formula:

Sum max number of consecutive positive numbers: (Note: D2 is the cell of the consecutive positive numbers you have counted by the using the formula in this article, please press Ctrl + Shift + Enter keys together)
=MAX((COUNTIF(OFFSET(A2:A18,ROW(A2:A18)-ROW(A2),0,D2),">=0")=D2)*SUBTOTAL(9,OFFSET($A$2:$A$18,ROW(A2:A18)-ROW($A$2),0,D2)))

Sum max number of consecutive negative numbers: (Note: E2 is the cell of the consecutive negative numbers you have counted by the using the formula in this article, please press Ctrl + Shift + Enter keys together)
=MIN((COUNTIF(OFFSET(A2:A18,ROW(A2:A18)-ROW(A2),0,E2),"<0")=E2)*SUBTOTAL(9,OFFSET($A$2:$A$18,ROW(A2:A18)-ROW($A$2),0,E2)))

Please try, hope it can help you!
This comment was minimized by the moderator on the site
how do you count consecutive occurrences of two different values or numbers
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations