Conditionally highlighting totals that don't match a dynamically summed range - excel

Objective:
I am looking to use conditional formatting to highlight cells in rows that are not equal to the sum of a dynamic range.
Problem:
While the formula I have created seems to work when pasted into cells, it does not give the same results when entered as a conditional formula.
Example:
Here is a space delimited example to be pasted into "A1":
Allo d1 d2 d3 d4 d5
Total 10 10 10 10 10
A 9 9 10 10 9
B 0 0 0 0 0
C 0 1 0 0 0
Total 12 12 12 12 12
B 0 5 0 3 4
C 12 7 8 8 8
Total 12 12 12 12 12
A 0 0 0 0 0
B 0 0 0 0 0
C 0 5 0 3 4
D 12 7 8 8 8
I wrote this formula which shows TRUEs and FALSEs correctly when pasted into "H2" and dragged to the right and down to "L13." When I apply this formula to the data range "B2:F13" it does not mimic what I'd expect.
=IF($A2="TOTAL", B2 <> SUM(INDIRECT(ADDRESS(ROW(B3),COLUMN(B3),4)&":"&ADDRESS(ROW(B2)+IFERROR(MATCH("TOTAL",$A3:$A$13,0)-1,ROW($A$13)-ROW($A2)),COLUMN(B2),4))))
Below you can see the formula broken out in a more easy to read way. Is my formula flawed/ How can I accomplish what I am trying to do? I appreciate your thoughts.
=IF($A2="TOTAL",
B2 <> SUM(
INDIRECT( ADDRESS( ROW(B3),
COLUMN(B3),
4) &":"&
ADDRESS( ROW(B2) + IFERROR(
MATCH( "TOTAL", $A3:$A$13, 0)-1,
ROW($A$13)-ROW($A2)),
COLUMN(B2),4))))

Use OFFSET instead:
=IF($A2="TOTAL",B2<> SUM(OFFSET(B3,0,0,IFERROR(MATCH("TOTAL",$A3:$A$13,0)-1,ROWS($A3:$A$13)),1)))

Related

Cumulative sum in excel with certain criteria

I have typed out an equation that I have dragged it down in a column in my excel table. I think I’m fairly close… and would love some feedback around this.
I want cumulative sum of the first cell $J$3 to the cell row it’s currently on (J53 for example). And I want cumulative sum of the particular cells that meet these conditions (ie… COUNTIF($B$3:B53,B53)*COUNTIF(AC53,1).
I know the Sumif() statement below isn’t correct… but this was as close as I could get!
=IF((COUNTIF($B$3:B53,B53)*COUNTIF(AC53,1)),(SUMIF($J$3:J53,J53)),0)
As shown in the table below
Projectid(B)
successornot(AC)
production(J)
result I want
1
1
20
20
1
1
40
60
1
1
10
70
2
0
20
0
2
0
400
0
3
1
20
20
4
0
1
0
5
0
24
0
6
0
50
0
7
1
10
10
7
1
40
50
7
1
20
70
Give a try on
=IF(B2=0,0,SUMIFS($C$2:$C2,$A$2:$A2,A2,$B$2:$B2,">0"))

Excel multiple search/match and sum (edit: answered with SUMIFS, COUNTIFS)

I am looking for help to solve this excel problem.
Essentially I want to create a formula for cells in column F which does a multiple search on 3 criteria (on cells in columns A,B,C) and want to access the corresponding column D values where all these (multiple) matches occur, and sum this in column F. I'd also like a count of the amount of matches found to calculate the value in column F; placed alongside in column G.
e.g.
IF col_A_value (anywhere in whole A column) = current_col_A_value +/- 1
AND col_B_value (anywhere in whole B column) = current_col_B_value +/- 1
AND col_C_value (anywhere in whole C column) = current_col_C_value - 1
THEN (output in column F) the sum of all values from row D where this criteria is met
(also, as a seperate but related cell formula, output in column G) the total Count of times this occurs.
Note: the values in columns A,B,C are all integars and the +/- above means to search for any values which are either +1, 0, or -1 different in value. (i.e. this includes the value itself).
e.g. If the value in cell A1 = 10, B1 = 45, C1 = 881, then the first search criteria would look for all other rows with values of 9, 10 or 11 in column A. Then based on these rows, the second search criteria would refine the search to only those rows which also include either a 44, 45 or 46 in column B, and the third search criteria would refine the search again to only include those rows where the column C value is 880.
Next, the values in the column D cells from all of these 'filtered' rows would be summed and the result placed in the column F cell. (The count of these results rows would be put in column G. (seperate formula required))
Since these are all unique entries (think of columns A,B,C creating unique vector coordinates in space), there should be a maximum of 9 entries found and summed. A +/-1: 3 variations, B +/-1: 3 variations and C -1 only: 1 variation. In total: 3x3x1 = 9 unique rows maximum (and potentially none as a minimum, as in the below example).
(If no match is found a value of 0 is good.)
Example with A,B,C,D and E as given values, and column F values calculated (together with the count shown in col G):
A B C D E F G
1 1 1 90 8 0 0
1 2 1 80 6 0 0
1 3 1 70 1 0 0
1 4 1 60 6 0 0
2 1 1 50 1 0 0
2 2 1 40 8 0 0
2 3 1 30 6 0 0
2 4 1 20 8 0 0
3 1 1 10 8 0 0
3 2 1 11 6 0 0
3 3 1 12 1 0 0
3 4 1 13 1 0 0
1 1 2 99 8 260 4
1 2 2 89 6 360 6
1 3 2 79 1 300 6
1 4 2 69 6 180 4
2 1 2 59 1 281 6
2 2 2 49 8 393 9
etc
To illustrate how column F values are calculated here is the working:
260 = 90+80+50+40
360 = 90+80+70+50+40+30
300 = 80+70+60+40+30+20
180 = 70+60+30+20
281 = 90+80+50+40+10+11
393 = 90+80+70+50+40+30+10+11+12
Thanks a lot for any help with this!
These formulas should do what you desire:
F1: =SUMIFS(D:D,A:A,"<="&A1+1,A:A,">="&A1-1,B:B,"<="&B1+1,B:B,">="&B1-1,C:C,C1-1)
G1: =COUNTIFS(A:A,"<="&A1+1,A:A,">="&A1-1,B:B,"<="&B1+1,B:B,">="&B1-1,C:C,C1-1)
The formulas can simply be copied down as you need them...
(Still I don't know what col E is for)

In excel, how to use an array formula to sum a range to offsets of itself, generating a new "sum" range?

I'd like to use an array formula to sum a range to multiple offsets of itself: for example, given the following range: {3,4,5,6,7} (say in cells A1:A5), I'd like to get the range added to itself, say 4 times, but each addition is offset by one column. So the answer would be a range equal to {3, 3+4, 3+4+5, 3+4+5+6, 3+4+5+6+7, 4+5+6+7, 5+6+7, 6+7, 7}
Here is an example, offset by rows:
3
4 3
5 4 3
6 5 4 3
7 6 5 4 3
0 7 6 5 4
0 0 7 6 5
0 0 0 7 6
0 0 0 0 7
=
3
7
12
18
25
22
18
13
7
Put the following in your first desired cell:
=IF(ROW(1:1)< COUNT($1:$1)*2,SUM(INDEX($1:$1,IF(ROW(1:1)<COUNT($1:$1),1,ROW(1:1)-COUNT($1:$1)+1)):INDEX($1:$1,MIN(ROW(1:1),COUNT($1:$1)))),"")
Then copy down. As numbers are added or subtracted from the first row the answer will change to match. Just copy down sufficient rows to cover twice the greatest number of values in row 1.

Grouping records whle filling gaps with zero

1 2280
3 1250
5 1245
9 1258
But I need a result like this:
1 2280
2 0
3 1250
4 0
5 1245
6 0
7 0
8 0
9 1258
10 0
May be this formula would be easier.
=IFERROR(VLOOKUP(D1,$A$1:$B$10,2,FALSE),0)
Put these two formulas in D1:E1.
=ROW() '◄ D1
=IFERROR(IF(ROW()<INDEX(A:A, MATCH(ROW(),A:A )+(ROW()>1)-ISNUMBER(MATCH(ROW(),A:A, 0))), 0, INDEX(B:B, MATCH(ROW(),A:A, 0))), 0) '◄ E1
Fill down as necessary. Copy and Paste Special, Values in place to revert the formula results to their values and delete columns A:C.
        

excel:compare 2 columns and copy data on other columns

need help.. i trying to compare 2 columns and copy data in other columns..
Columns:
A B C D
1 3 10
2 4 20
3 1 30
4 2 40
5 0 50
i want to compare column A to B to find its duplicate and copy data from column C if column A has a duplicate at column B...
Result must be:
A B C D
1 3 10 0
2 4 20 40
3 6 30 10
4 2 40 20
5 0 50 0
thanks in advance...
An answer as I understand the question (assuming the change in col B is just a typo):
Input
A B C D
1 3 10
2 4 20
3 6 30
4 2 40
5 0 50
Output
A B C D
1 3 10 0
2 4 20 40
3 6 30 10
4 2 40 20
5 0 50 0
Formula in D2 (filled down): =IF(COUNTIF(B$2:B$6, $A2)>0, VLOOKUP($A2,$B$2:$C$6, 2, FALSE), 0).
COUNTIF(B$2:B$6, $A2) returns the number of times the value in A2 appears in the array B2:B6. If this value is greater than 0 (meaning that A2 is in B2:B6), the IF() function looks looks up A2 in col B and returns the value in the 2nd row (col C); if A2 is not in B2:B6, the formula returns 0.

Resources