I am trying to make a table where a cell in each subsequent row subtracts from the previous one to show the change between the two. The problem is each row isn't always populated so something like A2-A3 then A3-A4, A4-A5, etc. will not work.
How can I skip blank rows in the formula to achieve a result like shown in the attached image (A6 being subtracted from A3 since A4/A5 are blank).
Thanks,
In b3,
=if(a3<>"", abs(a3 - index(a:a, match(1e99, a$1:a2))), "")
I wasn't sure how you wanted to handle the subtraction so I made the difference an absolute value.
Related
This gets a bit too expert for me, hopefully one of you can help me!
See the image for what I am trying to achieve. The red text shows what I want. List3 contains all the possible values for List1. List2 displays the currently active values for List1, and I want to return the missing values based on List3.
I'm guessing I'm looking at a MATCH/INDEX/IF function but I cannot figure this one out. Anyone out there willing to give me a hand? <3 Thanks a bunch!
Put this formula in F4 and fill down.
=INDEX(C:C, AGGREGATE(15, 7, ROW(C$2:C$11)/NOT(COUNTIFS(B:B, C$2:C$11, A:A, E4)), COUNTIF(E$4:E4, E4)))
Of course, this formula is dependent on the list of 'numbers' in E4:E7 being accurate and sufficiently populated to catch all missing entries.
Reference the image below. Use this formula to get the number missing:
=SUMPRODUCT(--(A2:A40<>A1:A39))*ROWS(C2:C12)-ROWS(A2:A40)
Change A40 to the last cell of your data in column A and A39 to the second to last cell.
Then enter this helper column as an array formula (Ctrl+Shift+Enter) into a 1-column range with the same number of rows that the formula above returns (it encodes the missing pairs into a single number). I entered it into D4:D8:
=SMALL(IFERROR(0>MATCH(INDEX(A2:A40,INDEX(SMALL(IF(A2:A40<>A1:A39,ROW(A2:A40)-ROW(A1)),ROW(INDIRECT("1:"&SUM(--(A2:A40<>A1:A39))))),INT((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1)/ROWS(C2:C12))+1))&INDEX(C2:C12,MOD((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1),ROWS(C2:C12))+1),A2:A40&B2:B40,0),INDEX(SMALL(IF(A2:A40<>A1:A39,ROW(A2:A40)-ROW(A1)),ROW(INDIRECT("1:"&SUM(--(A2:A40<>A1:A39))))),INT((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1)/ROWS(C2:C12))+1)*ROWS(C2:C12)+MOD((ROW(INDIRECT("1:"&ROWS(C2:C12)*SUM(--(A2:A40<>A1:A39))))-1),ROWS(C2:C12))+1),ROW(INDIRECT("1:"&SUM(--(A2:A40<>A1:A39))*ROWS(C2:C12)-ROWS(A2:A40))))
Again, change A40 to the last cell of your data in column A and A39 to the second to last cell.
Next, enter this formula into E4 and fill down:
=INDEX($A$2:$A$40,INT(D4/ROWS($C$2:$C$12)))
Finally, enter this formula into F4 and fill down:
=INDEX($C$2:$C$12,MOD(D4,ROWS($C$2:$C$12)))
I'm working on a budget for a project with multiple phases. There is a possibility that not all phases will be worked on so I've added some lookups and SUMIF formulas so that I can get a summary of my included and excluded effort and dollar amounts. That all works fine. Now I'd like to hide my row of lookups (row 1), but still have a way of identifying which phases of the project are included and which are excluded. Obviously I could manually concatenate them together, but if the phases being included/excluded change then I need to remember to update those formulas (and it's not nearly as fun as doing all in a formula). Here's how my sheet looks:
The TEXTJOIN function seems like it should work (i.e. =TEXTJOIN(CHAR(10), TRUE, C2:N2)), but I can't wrap my head around how to make the range parameter dependent on my lookup row. I played around with INDEX using something like =TEXTJOIN(CHAR(10), TRUE, INDEX(A2:M2,,(A1:M1="Yes")*COLUMN(A1:M1))), but didn't have any luck. At the end of the day I want to have something like:
Phase 1 Phase 2 Phase 5
Please note that the above data should all appear in the same cell - using the line feed character, CHAR(10), as the delimiter in the TEXTJOIN function will make all of the phases appear on a new line within a single cell. I do not want to fill formulas through multiple cells. Thanks in advance for any help.
Please take a look at the picture. I had a similar issue in the past (and brought it to StackOverflow, at which point I was helped by #ScottCraner, original post here:
Doing an array formula lookup
Basically,
1) You set up the array you are looking through - in my case, its $A$2:$A$6, in your case it will be $B$2:$M$2.
2) You then nest the COUNTIFS function inside of a match function. The function does the following:
A) It checks whether the name of phase X has already shown up in column E when you are copy/pasting down
B) If it has, move on to the next one
C) If it hasn't, output
3) Of note: this is an array formula, so the formula itself is checking through every cell. So it looks at cell A2; if the cell in B2 is "Yes", and "Phase 1" isn't in range in column E, then put in phase 1. Because it is, its there. Then it looks at cell A3; if the cell in B3 is "Yes", the same thing for phase 2. Then it looks at cell A4; because B4 is "No", the *(B2:B6="Yes") will throw an error. and so on
4) Place error catching brackets around the function.
A less elegant way to go about this, which doesn't require array formulas would be to use the secondary column's "Yes/No" as an index. This assumes the value in the secondary column is redundant- and repeating the primary column's "Yes" or "No."
In C1: =CONCATENATE(B1,COUNTIFS($A$1:B1,B1)) -
Repeat relatively for E1, G1, etc.
Somewhere separate (the below formula assumes Row 1 of the same worksheet), you could then use: =IFERROR(INDEX($2:$2,MATCH(CONCATENATE("Yes",ROW()),$1:$1,0)-1),"")
To look up "Yes1", returning "Phase 1" and autofill downward. IFERROR is used here to return blank when you run out of "Yes" results.
Hi all,
I have this excel where by I need to find the location of the item if they are found in column B.
So In my F column, I tried to write ifelse formula which didnt work.which is
=IF(D2="NULL","NONE",C((D2))).
My idea is if D2 is not null, use the value in D column to find the location in C column. In this example, fish no 4, so it is found, my F column should show the value "C" using the value shown in D column and use it as Row no in C column
I hope you guys get the idea and help me out a newbie in excel. Thanks in advance
=vlookup($D2,$A$2:$C$6,3,0)
you can use that in column F. Place that formula in F2 and copy down.
you could technically use it in column E as well, but you would need to change the 3 to a 2.
you did not say what you wanted to do if the D value was "Null" so I am going to take a stab at the dark and wrap you lookup formula in an if statement that will deal with "Null" or empty cells
=IF(OR($D2="NULL",$D2=""),"",VLOOKUP($D2,$A$2:$C$6,3,0))
That is the alternative formula to place in F2 and copy down.
Use the formula:
=IF(D2<>"NULL",VLOOKUP(D2,A2:C6,3,FALSE),"Value is NULL")
Here is the working example:
Put formula in cell F2 and drag it down.
[edit]to pull proper location column, not just the row #[/edit]
Seems like a job for MATCH+OFFSET
Try this formula in cell F2:
=OFFSET($C$1, MATCH(E2,B:B,0)-1, 0, 1, 1)
Match is used to locate the value in the first argument (ie E2) within the range specified in 2nd argument (ie B:B). I use B:B but you could also use range B2:B30 or whatever more specific range you want. (I prefer the more generic B:B, though :) )
Third paramter "0" just indicates "Exact match".
This function will retun "#N/A" if nothing found.
OFFSET takes the result from MATCH to pick out the Location you want. The first parameter in OFFSET is the rows below (or above if negative) from the base row (in this case $C$1). the next is the column: 0 since we're in the column we want to be in. The last two are the size of the range: 1,1 is a 1x1 cell, so just 1 cell. If we did ...,2,3), that would be 2 rows high and 3 columns wide - or a 6 cell range. We're just after 1 cell here.
I've always preferred MATCH + OFFSET to other options, I just found they held up more robustly to changes in a sheet (ie new rows/columns added). So it's mostly personaly preference over VLOOKUP and INDEX. I honestly have never compared their actual performance, however, I've never had any issues with MATCH+OFFSET running slowly :)
I have an if statement working properly in only one cell. =IF(B28="Others",+C28, 0). However, I also want to include the cells B28 to B30 and will add C28 to C30 respectively in the formula. How will I be able to do so? I have tried this formula: =IF(B28:B30="Others",+C28:C30, 0) but it won't work.
What I want to happen is this:
I will input values in the cells C28:C30, and if they're under a certain category (ex. B28 says 'Others'), that value will be added to that category above (ex. C18 for 'Others').
If it works, C18 should have a value of 1,450 since 1,150 and 300 are both under 'Others'.
The function you're looking for is SUMIF(). You can read about it here.
The complete formula you need is: =SUMIF(B28:B30,"Others",C28:C30)
you might want to use a sumif statement where you're summing on the values in C based on the category in B
http://www.exceltrick.com/formulas_macros/excel-sumif-and-sumifs/
I created spreadsheet for budgeting purposes and have it set up so that every time I add some data in my income or expenses column, my balance column automatically posts a readjusted value. However, my formula only seems to work for positive values (see conflict on row 4 of example) Here's what I have so far, pasted in as an array formula in B3 and copied down.
=IF((ISNUMBER(C3:D3)),B2+C3-D3,"")
How could improve the "if true" section of my formula?
the problem you're having is your if statement will return false if either C or D is not a number. if(c through d is a number) will mean that it only is true when both are numbers.
If you want to make it so that you only evaluate numbers (and not treat blanks as 0), then you'll probably want to make an OR statement:
=IF(OR(ISNUMBER(C3),ISNUMBER(D3)),B2+C3-D3,"")
Just be aware that if the relative location of B2 is missing data (if you did not have any expense or income the previous day/week/whatever), then the next field will become a value error when you add something. So if B5 is empty because you didn't do any spending or gaining, then when you spend and put value in "expense" on D6, B6 will become #Value.
To fix this, it might be a good idea to finish off not with an empty string, but with the value of the previous date. It's up to you if you want to use it that way.
=IF(OR(ISNUMBER(C3),ISNUMBER(D3)),B2+C3-D3,B2)
You could try the following, applied on B3:
=IF(AND(ISBLANK(C3),ISBLANK(D3)),"",B2+C3-D3)
This way, you don't need an array formula - I'm just checking if C3 AND D3 are blank - if so, the cell will be empty, otherwise will do the math.
You could put an Or statement in so that if either C3 or D3 is a number, then calculate accordingly.
=IF(Or(ISNUMBER(C3),ISNUMBER(D3)),B2+C3-D3,"")