Grouping records whle filling gaps with zero - excel

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.
        

Related

How to multiply each row and then sum it with the product in the next row etc

I am trying to calculate total for each month based on Score and Number of occuruencies each month:
Category# Score Jan-18 Feb-18 Mar-18 Apr-18
category1 10 1 5 1 5
category2 8 2 4 2 4
category3 7 3 3 3 3
category4 6 4 0 4 0
category5 5 0 1 0 1
TOTAL 71 108 71 108
In the essence, for January I could type the following formula:
=($B$2*C2)+($B$3*C3)+($B$4*C4)+($B$5*C5)+($B$6*C6)
But it is very clumsy, so I am wondering if I could something more elegant and clean
that is what SUMPRODUCT is for
=SUMPRODUCT($B$2:$B$6,C2:C6)
Use SUMPRODUCT. It's exactly what you need:
SUMPRODUCT function
I replied your data:
The formula I have used is:
=SUMPRODUCT($B$4:$B$8;C4:C8)
After applying to first column (Jan-18), just drag it to the right, and it should return the right values, as you can see in the image.
Hope this helps!

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

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)))

how to change cells color per value next to it

I have the following set of 2 columns and n rows:
A B
1 44000 44000
2 2800 2730
3 17000 21160
4 1000 1046
5 700 0
6 1500 1249
7 300 107
8 1200 400
9 0 1400
10 4500 3582
11 0 280
I would like to create a Conditional Formatting rule for column B, so if value in any row exceeds the associated value in row A the cell becomes red: https://gyazo.com/83a45768c6952f5590448700059179ce
The problem with this approach is I have to modify every single cell and cannot apply the whole Rule for all cells in column B.
If I apply this rule to the set of cells in col A I receive: This type of reference cannot be used in Conditional Formatting formula: http://prntscr.com/feo3c0
The formula:
=$B1>$A1
The Applies to:
=$B:$B

Formula to find matching row value in multiple columns

I need a formula that would look in columns Jan, Feb & Mar to see if of the three months two months contained a 0, then in column 5 it would return the word win.
Store Jan Feb Mar Outcome
101 0
102 50 0
103 0 100
104 0 0 Win
105 0 0 Win
This should do the trick. (Placed in E2 and copied down)
=IF(COUNTIF(B2:D2,0)=2,"win","")
It counts how many zeroes are in columns B-D and if 2 then returns win

Excel - lookup on one column, result from second column

The first three columns exist. I am trying to create a formula for the fourth (HH_ANALYSIS_FLAG).
ACCOUNT_NUMBER HOUSEHOLD_NUMBER ACCOUNT_ANALYSIS_FLAG HH_ANALYSIS_FLAG
1001 1 1 0
1002 2 0 0
1003 3 1 0
1004 3 0 0
1005 3 0 0
1006 2 0 0
1007 4 0 0
1008 1 1 0
I have 50,000 accounts. They are flagged as being under analysis with the ACCOUNT_ANALYSIS_FLAG column (0,1). All accounts belong to a household. Multiple accounts can belong to the same household. I need the HH_ANALYSIS_FLAG column to evaluate to true or false (0,1) if any account in the same household is under analysis. So with the above data and a working formula, my spreadsheet would look like so:
ACCOUNT_NUMBER HOUSEHOLD_NUMBER ACCOUNT_ANALYSIS_FLAG HH_ANALYSIS_FLAG
1001 1 1 1
1002 2 0 0
1003 3 1 1
1004 3 0 1
1005 3 0 1
1006 2 0 0
1007 4 0 0
1008 1 1 1
The following formula should do the trick. In fact, it will give you the total number of accounts being analysed per household.
A B C D
1 ACC_NUM HH_NUM ACC_ANALYSIS_FLAG HH_ANALYSIS_FLAG
2 1001 1 1 =SUMIF(B$2:B$50001, B2, C$2:c$50001)
3 1002 2 0 =SUMIF(B$2:B$50001, B3, C$2:c$50001)
4 1003 3 1 =SUMIF(B$2:B$50001, B4, C$2:c$50001)
For each row this takes selects the set of rows that share the value in the ACC_NUM column (based on the row conaining the formula) and sums together the values in the corresponding ACC_ANALYSIS_FLAG columns. This gives you the total number of accounts under analysis for the given household. Compare the result to 0 if you only need to use it as a boolean value.
EDIT:
Apparently the performance of this isn't up to snuff. However, assuming the the household numbers are all colocated, it should be possible to speed things up significantly by changin to something like the following.
2 1001 1 1 =SUMIF(B2:B5, B2, C2:C5)
3 1002 2 0 =SUMIF(B2:B6, B3, C2:C6)
4 1003 2 0 =SUMIF(B2:B7, B3, C2:C7)
5 1004 2 0 =SUMIF(B2:B8, B3, C2:C8)
6 1005 2 0 =SUMIF(B3:B9, B3, C3:C9)
7 1006 2 0 =SUMIF(B4:B10, B3, C4:C10)
8 1007 2 0 =SUMIF(B5:B11, B3, C5:C11)
9 1008 2 0 =SUMIF(B6:B12, B3, C6:C12)
10 1009 2 0 =SUMIF(B7:B13, B3, C7:C13)
This assumes that there are at most 4 accounts per household, and thus limits the range of the SUMIF to the current cell +/- 3 rows.
To avoid referencing invalid cells you'll the first and last rows have to be treated as special cases. If you need to generate a single forumala for all of these cells I think it should be possible using the OFFSET in combination with MAX, MIN and ROW to generate the appropriate ranges with just a little arithmatic.
Insert another column D (you can hide it later), which is equal to the household number if it is being analyzed, and zero if it is not. The formula for D2 can be =B2*C2. Fill column D with this formula.
Then for your HH_ANALYSIS_FLAG column, you can count the number of values in column D which match the household in column B. The formula would be like IF(COUNTIF(D:D,"="&B2)>0,1,0).
I'm not sure whether this approach is fast enough for the 50,000 accounts, though.
A B C D E
1 ACCOUNT_NUMBER HOUSEHOLD_NUMBER ACCOUNT_ANALYSIS_FLAG HH_UNDER_ANALYSIS HH_ANALYSIS_FLAG
2 1001 1 1 1 (=B2*C2) =IF(COUNTIF(D:D,"="&B2)>0,1,0)
3 1002 2 0 0 (=B3*C3) =IF(COUNTIF(D:D,"="&B3)>0,1,0)
4 1003 3 1 3 (=B4*C4) =IF(COUNTIF(D:D,"="&B4)>0,1,0)
Presuming your HOUSEHOLD_NUMBER column is column B:
=IF(SUMIF(B:B,C:C)>0,1,0)
should do it.
Kenneth! Try this one:
=IF(VLOOKUP(B2,$B$2:$C$9,2,0)=1,1,0)
Assuming your table starts from A1, which means Account_Number is in cell A1, and your target column "HH_ANALYSIS_FLAG" is in column D.
Hope it's helpful

Resources