Excel-Is is able to return current result if the condition fails - excel

Below table describes what I expect for.
The "Count Blank" Column is a counter for counting continuous blank cells in order from Column A to Column C. If any of the following cell has value then stop counting and return current value. (plz see row6 and row7)
Basically, I'm looking for a formula which could return the current counter value if the condition fails.
Count Blank
Column A
Column B
Column C
0
1
2
3
1
2
3
2
3
3
1
2
0
1
These two formulas are just for counting the blank cells in the range:
=COUNTIF(B8:D8,"")
=SUM((IF((B8:D8)="",1,0)))
Hoping anyone can help with the continuous problem.
Count Blank
Column A
Column B
Column C
0
1
2
3
1
2
3
2(should be 1)
2
2(should be 0)
1

I found this: https://exceljet.net/formulas/get-first-non-blank-value-in-a-list
You don't really want to count anything, you just need to find the first non blank cell. You can try this formula:
=IFERROR(MATCH(FALSE;ISBLANK(B2:D2);0)-1;COLUMNS(B2:D2))
This is an array formula, so press ctrl+shift+enter when entering it into a cell.

You can use the new (as of 2020) reduce and lambda functions:
=VALUE(REDUCE(0, B1:D1, LAMBDA(prev, curr, IF(ISTEXT(prev), prev, IF(curr = "", prev + 1, TEXT(prev,"0"))))))

Related

Look up for highest value from another column if values are equal excel

***1 2 3***
a 2 3
b 3 4
c 4 3
d 5 2
so I know to get the highest value I do
=INDEX(column1, MATCH(MAX(column3), column3, 0))
... which would give me 'b'
now I want to get the second highest value based on the column 3 but because there are two cells with 3 (which is the second highest value) I want to use the one that has the lowest value in column 2 based on those two rows. Is this possible?
Use a 'helper' column that adds column C + (column B ÷ 10) and use a modification of your original formula on that column.
        
The standard formula in F5 is,
=INDEX(A$2:A$5, MATCH(AGGREGATE(14, 6, D$2:D$5, ROW(1:1)), D$2:D$5, 0))
Fill down as necessary.

Keep on summing corresponding cell and compare with first column for summing up first column based on comparision in excel

Consider the following data setup:
_A_ _B_ _C_
1 1
2 1 1
3 3
Such that a formula would return the following results for columns B and C respectively:
_A_ _B_ _C_
4 2
Now I want to sum column A if A-(B+C) is equal to 0.
so for above example sum would be 1+3 = 4 on column B, since row 1 and 3 satisfy 1-1=0 first row, 3-3=0 third row. so A value on 1st and 2nd row is 1+3=4. Row 2nd doesn't satisfy 2-1=1 not 0 so ignore.
on column C, B+C in second row 2-(1+1) = 0 ,So it would be sum 2 in that column C, ignoring first and third row since it already has been counted on column B.
columns continue like D E....
So sum up from B to current column..so if i am in column B it will sum up till B.If in C B+C....If in D B+C+D etc and then compare with column A
Insufficient rep to comment, this is at least a partial answer and perhaps full.
I think you're looking for this to happen in some lower row in B:
=SUMPRODUCT(--(A1:A3=B1:B3),A1:A3)
And this in C:
=SUMPRODUCT(--(A1:A3-(B1:B3+C1:C3)=0),A1:A3)
Although as EEM points out all the sample rows satisfy this condition so you get "6" instead of "2"

Find last non-zero cell's column reference in an UNORDERED range of values

I have a range with numbers in a row in Excel, say:
A B C D E F G H I J K L
Line 1 => 0 0 0 3 2 8 3 6 0 0 0 0
All cells are non-blank but some contain zeros and some contain numbers. Also, the range cannot be ordered in either ascending or descending order.
I need a formula (not VBA) that will return the column of the last non-zero value in the range (i.e. column 8 for cell H1 above). I can get the actual value of cell H1 with this formula:
LOOKUP(2,1/(A1:A10<>0),A1:A10)
but I cannot find a way to get the column number for that cell.
Any ideas?
You are very close:
=LOOKUP(2,1/(A1:L1<>0),COLUMN(A1:L1))
Enter
=MAX(IF(YourRange=0,0,COLUMN(YourRange)))
as an array formula (CTRL-SHIFT-ENTER).
For me, the best solution for numeric values was this:
=IF(D497<>0,D497,IF(D496<>0,D496,IF(D495<>0,D495,IF(D494<>0,D494,IF(D493<>0,D493,D492)))))
it gives the last non zero value, for your require range that you can make by adding further rows to the formula.

How to count number of matches between two columns in Excel?

How to count number of matches between two columns in Excel?
For example if we have:
1 1
2 1
3 2
4 4
5 3
I need to get either a column like this:
1
0
0
1
0
and then I can sum the ones in there to get the count of matches.
Option 1: IF
=IF(A1=B1;1;0)
This formula will put 1 in the cell if A1 = B1, and 0 otherwise.
Option 2: COUNTIF
Write =A1=B1 in C1, etc., in the column cells. This will fill the C column with TRUE and FALSE values.
At the bottom of that column, add a cell =COUNTIF(C1:C100;TRUE) so that you count the cells between C1 and C100 which have value TRUE.
You may find the TechRepublic article Use COUNTIFS() to compare two data sets in Excel of use. See also Microsoft's documentation on countifs().

Compare in two columns and add value

I have 2 columns looking like this:
Column 1 Column 2
1 x
x 2
2 2
x x
1 2
I want to do two things;
For each row match (row n column 1 = row n column 2) it should mark cell n in column 1 green if there is a match and red if it is not.
It should create a sum cell where each match is worth 1 point, in this case column 1 should result in 2 points.
Is this even possible with excel and if so, how is it done?
For the first part of your question:
It should mark cell n in column 1 green if there is a match and red if it is not
You can do this using Conditional Formatting.
Ex:
Assume column A and column B, with the values starting in row 2.
The following conditional formatting would highlight column A values in green if they match the corresponding value in column B in the same row, otherwise red.
Highlight the values in column A, then apply this conditional formatting.
For the second part of your question
It should create a sum cell where each match is worth 1 point, in this case column 1 should result in 2 points
The following array formula will tally all the matches and show you how many there are:
=SUM(IF(A2:A6=B2:B6,1,0))
Assuming again that we are in columns A & B with your sample data.
Remember to commit this formula using Ctrl+Shift+Enter.
Per comment from andy holaday, here is another formula that will work:
=SUMPRODUCT(N(A2:A6=B2:B6))
or
=SUMPRODUCT(--(A2:A6=B2:B6))
These are not CSE formulas so you would not need Ctrl+Shift+Enter to commit them.

Resources