Excel formula to Count zeros only from Left to Right - excel

I am currently using the following formula (i.e. =IF(A9<>"0";COUNTIF(A9:L9;"0");" ")) in a range "Jan to Dec" to get the number of zeros from left to right only and it is giving me 3 for 1st row, second & third rows as well. But what I want is, it should count zeros only from left to right (only in first and third cases). Only in second case it should not count zeros, because they are coming after some value, but it should count in 1st case and 3rd cases.
Can someone please help me with the formula?
Jan Feb Mar Apr May Jun Jul
0 0 0 5 10 15 20
10 15 20 25 0 0 0
50 0 0 0 30 35 40

Per comment conversation with OP vbalearner, assuming your data setup and desired results look something like this:
Then the formula in the cell and copied down is:
=IF(A9=0,IFERROR(MATCH(TRUE,INDEX(A9:L9>0,),0)-1,12),IF(B9=0,IFERROR(MATCH(TRUE,INDEX(B9:L9>0,),0)-1,12),0))
Shortened version:
=IF(OR(A9=0,B9=0),IFERROR(MATCH(TRUE,INDEX(IF(A9=0,A9:L9,B9:L9)>0,),0)-1,12),0)

With a helper row inserted at the top (may be hidden) with month numbers (1 for Jan etc) and assuming Jan is then in A2 please try:
=MIN(IF(A3:G3<>0;A$1:G$1))-1
entered with Ctrl+Shift+Enter and copied down to suit.

Related

How return substring of count for override for found december?

I have a spreadsheet that will always return varying row contents. So I need to search each row to find the january, february, march, april, may, june, july, etc content and extract the counts from that in the cell with substring. I'm not certain how to do this since the location in the row will always vary. Any ideas? I was thinking vlookup or index or match, or mid/search, but I'm not sure.
Example spreadsheet content, notice some rows have the overallCount and some have overrideCount, and a string like "overallCount 2022/12 35" is the complete cell value, where 2022 is the year, and 12 is the month:
result1 result2 result3 result4
overallCount 2023/01 11 overallCount 2022/12 35 overallCount 2022/01 12 overrideCount 2022/08 5
overallCount 2023/02 1 overallCount 2022/11 34 overrideCount 2022/02 9 overrideCount 2022/01 5
------ (3 rows) OverrideYearOrders overrideCount 2022/10 2 overallCount 2023/01 6
And the rows can have varying column numbers as well if there are more or less orders for each device.
I want to add a formula in result8 column or so, and search to the left of each row, and pull out the counts in columns for Jan, Feb, March, April, May, etc. I was thinking of something like this:
=VLOOKUP("overrideCount 2022/12",H6:AC8517,1,FALSE)
but it's not returning the count. It's returning #N/A
example per-row output on the right:
Overall Override
Jan2022 Feb March April May June July Aug Sept Oct Nov Dec Jan2023 Jan2022 Feb Mar ...
35 11 5
As you can see, not every month has a count that would be found in the row.
How would I pull those monthly counts for overall and override out to the right in each row?
Update*
This is the generated table per comment below:
result1
result2
result3
result4
result5
Output to right here Overall Jan2022
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Override Jan2023
Override Jan2022
Feb
overallCount 2023/01 11
overallCount 2022/12 35
overallCount 2022/01 12
overrideCount 2022/01 5
35
11
5
overallCount 2023/02 1
overallCount 2022/11 34
overrideCount 2022/02 9
overrideCount 2022/01 5
34
5
9
------
(3 rows)
OverrideYearOrders
overrideCount 2022/10 2
overallCount 2023/01 6
6
Example output is shown to right in generated table above, and also example per-row output is given in this before this added update already.
FORMULA:
This formula will get you to where you want pending a couple changes.
Rename the column headers to represent the date you want to calculate for (1/1/2022, 2/1/2022, ...).
This formula requires every cell value to "search" to be of "overallCount yyyy/mm" or "overrideCount yyyy/mm"
format
Drag and drop the formula for as far as you need it (row and columns).
First formula, totaling overallCount (F2:s2)
=IF(SUMPRODUCT(--IFERROR(SEARCH("overallCount "&TEXT(F$1,"yyyy/mm"),$A2:$E2)>0,FALSE)*SUMPRODUCT(--IFERROR(RIGHT($A2:$E2,LEN($A2:$E2)-(FIND("overallCount "&TEXT(F$1,"yyyy/mm"),$A2:$E2)+20)),0)))>0,SUMPRODUCT(--IFERROR(SEARCH("overallCount "&TEXT(F$1,"yyyy/mm"),$A2:$E2)>0,FALSE)*SUMPRODUCT(--IFERROR(RIGHT($A2:$E2,LEN($A2:$E2)-(FIND("overallCount "&TEXT(F$1,"yyyy/mm"),$A2:$E2)+20)),0))),"")
Second formula, totalling overrideCount (R2:AG2)
=IF(SUMPRODUCT(--IFERROR(SEARCH("overrideCount "&TEXT(T$1,"yyyy/mm"),$A2:$E2)>0,FALSE)*SUMPRODUCT(--IFERROR(RIGHT($A2:$E2,LEN($A2:$E2)-(FIND("overrideCount "&TEXT(T$1,"yyyy/mm"),$A2:$E2)+21)),0)))>0,SUMPRODUCT(--IFERROR(SEARCH("overrideCount "&TEXT(T$1,"yyyy/mm"),$A2:$E2)>0,FALSE)*SUMPRODUCT(--IFERROR(RIGHT($A2:$E2,LEN($A2:$E2)-(FIND("overrideCount "&TEXT(T$1,"yyyy/mm"),$A2:$E2)+21)),0))),"")
EXPLANATION:
The formula is using the SUMPRODUCT function which multiplies the corresponding elements of the arrays and returns the sum of products.
The formula uses the SEARCH function to look for the occurrence
of the string in the cells using the format
"yyyy/mm", in the cells of the range A2:E2 and returns TRUE if
found, otherwise returns FALSE.
The formula uses the IFERROR function to check for errors and returns
0 if error is found.
The formula uses the RIGHT function and is used to extract the rightmost
part of the cell, starting from the position of the found string -20/-21 (calculation that takes advantage of the date in the column header plus its position in order to autofill). In short, it totals the number after the date.
EXAMPLE:
The following formula is the root formula that is just wrapped in an IF THEN statement to show empty cells instead of 0's. This formula is written assuming Cells A1:E1 are the 'results' headers, and starting at Cell F1 is the date start of your dates. (Jan22-Feb23 of each category)
SUMPRODUCT(--IFERROR(SEARCH("overallCount "&TEXT(F$1,"yyyy/mm"),$A2:$E2)>0,FALSE)*SUMPRODUCT(--IFERROR(RIGHT($A2:$E2,LEN($A2:$E2)-(FIND("overallCount "&TEXT(F$1,"yyyy/mm"),$A2:$E2)+20)),0)))

count and sum function not properly working

I am working in excel and for some reason my sum or count function is not working properly. Or, perhaps I am not using the correct function or in the right way.
A B C D E F G H
February Max March Max
1 28
2
3
4
5
7
11
15
17
19
22
23
25
IF(SUM(A:A>0),28,"")
IF(SUM(E:E>0),31,"")
I have the above columns, I want the Max columns to show a specific number only if there is data in their respective month column. February has data, so it shows 28. March does not have any data so it shows no max. I need to look at the entire column or at least a large area (row 2 to row 2000).
The issue I am having is that if I do not have a value in the first row, but do have values in later rows, the sum or count function will to recognize that and will return zero.
A B
February Max
3
4
5
7
11
15
17
19
22
23
25
IF(SUM(A:A>0),28,"")
I have tried both sum and count functions, neither are giving me the results I want. I have also tried making >= 1. I found from StackExchange that someone was having a similar problem and a solution was to change the cell format to a number. That did not work either. Any suggestions?
Per my comment, you could use COUNTA() which checks if a cell is blank.
While it doesn't answer the technical reason SUM/COUNT isn't working, it should work for your intended purposes.
=IF(COUNTA(A:A)>0,28,"")

Excel calculate the number of calendar days between two dates for individual months

I need to automatically calculate the number of calendar days between two dates for individual months
EG:
Start End Jan2014 Feb2014 Mar2014 Apr2014 May2014
18/11/2013 9/03/2014 31 28 9 0 0
7/04/2014 18/05/2014 0 0 0 23 18
....
you can use this formula in C3 copied across and down if required
=MAX(0,MIN(EOMONTH(C$2,0),$B3)-MAX(C$2,$A3+1)+1)
Assumes that dates in C2 and across are all 1st of the relevant month

Working with output of PI break sets of numbers, remove numbers

I have a list of numbers outputted from a review of PI (the number 3.1415926535897932384......)
It looks like this:
8850838032 0621312483 8327044318 1257233570 9958940293 1391776730 2923888859 5836058683 5192760238 4694561699 : 110000000001
9312900154 4838526183 9375914106 9846458403 5847003707 2451543553 9394699328 5157228504 5434270590 6509736487 : 110000000002
1284090545 3175919151 4159855781 3410862263 2549812643 7600394225 7109902021 0694219181 6542482795 7164656581 : 110000000003
1367977800 8915483236 6072599505 1466161901 1090687303 7608155585 3289637107 6490574006 0401938787 7258319674 : 110000000004
the list is in notepad (.txt file)
set of 10 digits per number
set of 10 numbers per line (10 digits per x 10 numbers per line)
reference number at the end ( the : 110000000001 : 110000000002 etc numbers)
Heres what I would like to do:
to remove the reference numbers first ( the : 110000000001 : 110000000002 etc numbers)
to break each set of 10 digits into 5 sets of 2 digit numbers, with each 2 digit number appearing on a seperate line of its own - 0621312483 to 06 21 31 24 83
from this I want to remove all 2 digit numbers over 26, so that I am only left with numbers from 01 - 26 - from 06 21 31 24 83 to 06 21 24
Seems might only be (have been?) required the one time so may be simpler to give the results:
6 21 24 4 18 12 23 2 13 23 5 2 16
12 1 6 3 0 7 24 22 4 5 9
12 9 5 10 22 25 26 0 25 9 20 21 6 21
13 0 15 5 14 16 19 1 10 3 8 15 7 6 4 1
(which don't end in the way indicated in the question) but the process was, assuming 8850838032 .... in A1:
Text to Columns with : as the delimiter, delete ColumnB.
="'"&TRIM(SUBSTITUTE(A1," ","")) in ColumnB copied down to B4.
Select ColumnB, Copy, Paste Special, Values over the top.
Text to Columns on ColumnB with Fixed width (first one character then every second).
Delete ColumnB.
Select B1:AY4, HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=B1>26
Format..., select a colour fill, OK, OK.
Select and Copy B1:AY4, say to AZ2, with Paste Special, Transpose.
Filter ColumnAZ by colour to select those coloured and blank out each selection then reselecting (Select All).
Repeat for ColumnsBA, BB and BC.
Tidy up to suit, eg by selecting AZ>BC, HOME > Editing - Find & Select, Go To Special, Blanks, select, Delete..., Shift cells up and then moving the contents of BA under AZ, etc and deleting what is not required.
.

Rolling Time LookBack Calculation

I'm sorry if this has been answered. I've been searching around for awhile now.
I have a times series dataset that I need to perform calculations on based on the previous x time (last hour,day, etc).
My issues is that I don't know how to run these calculations since the time deltas are not standardized.
Example:
Column A - Time (in seconds lets say)
Column B - Value
Time Value Result(5)
01 3 0
02 5 3
04 4 8
07 8 9
09 6 12
13 4 6
14 4 10
15 1 8
22 9 0
33 7 0
How could I return the Result(5) column by summing the last 5 seconds from that one instance (row) (not including it)?
Thank you.
EDIT:
To clear up what I'm trying to do:
1) Find the previous 5 secs of data using column A and return that range of rows
2) Using that range of rows for the 5 previous secs, sum column B
3) Output in Column C (formula)
The following formula should do what you need (paste into C2 and drag down):
=SUMIFS($B$2:$B$11,$A$2:$A$11,">="&A2-5,$A$2:$A$11,"<"&A2)
Where YourTime is the time in the row you wish to look back and sum over.
I've tested and it works for the data you provided - expand the ranges as appropriate.

Resources