Not sure which functions or combination of possibly vlookup, index, match, or aggregate will work best for this. So far I have spent more than two weeks and can't seem to determine what works. SO, thank you greatly for the one who can figure this puzzle out.
My goal is to determine how to write a formula that will show these results. My guess is that second formula etc. will be different from the initial as it will start with the row specified from the initial formula as we are interested in knowing what row a trend begins moving up or down based on the given change value.
Based on change of value .15
Results need to be:
13 Up (initial formula)
23 Down (continuing from row 13 ???)
Etc.
Based on change of value .10
Results need to be:
13 Up (initial formula)
17 Down (continuing from row 13 ???)
19 Up (continuing from row 17 ???)
Etc.
Hopefully I am explaining this well. Thank you, thank you, thank you to the person who can figure this out.
1 277.54
2 277.50
3 277.43
4 277.47
5 277.49
6 277.50
7 277.40
8 277.39
9 277.44
10 277.42
11 277.36
12 277.28
13 277.23
14 277.50
15 277.54
16 277.55
17 277.58
18 277.56
19 277.46
20 277.57
21 277.60
22 277.67
23 277.71
24 277.67
25 277.43
26 277.35
Here is one of my many attempts. =AGGREGATE(15,6,ROW(1:26)/(($A$1-A2:A26)>=$I$1),1)+1
First row of >= to .15 difference (row 8) is not adequate
Image showing inadequate result
Because the uptrend based on a change of .15 actually started up at row 13.
Correct example
Image of what it should look like:
What it should look like image
Well finally I have an answer. You will need two more columns to do it on my way (which I think you can hide).
First step - To know when a new trend starts, put this formula in your B2 and pull down till B26
=IF(A1-A2)(A2-A3)<0,IF(A2-A3<0,"Up","Down"),"")
Now you have on B exacly when started a new trend and which trend*
EDIT: Now use this formula on B2. After, you need to pull it also to B1 to generate data, and pull down until B26). After pull to B1, don't pull down directly from B1, because there will be an error in the formula, always pull from mid rows formulas. You need to close it with ctrl+shift+enter
=IF(OR(ROW(A2)=SMALL(ROW($A$1:$A$26),1),ROW(A2)=LARGE(ROW($A$1:$A$26),1)),"tail",
IF((A1-A2)*(A2-A3)<0,
IF(ABS(A2-INDIRECT("A"&LARGE(IF(LEN($B$1:B1)>0,ROW($B$1:B1),""),1)))>$K$1,
IF(A2-INDIRECT("A"&LARGE(IF(LEN($B$1:B1)>0,ROW($B$1:B1),""),1))<0,"Up","Down"),
""),
"")
)
Second step - To know when your value jumped >= than the value you input in cell K1 (e.g 0.15), put this formula in your C2 and pull down till C26 (close it with ctrl+shift+enter, it's an array formula)
=IF(ABS(A2-A1)>=$K$1,LARGE((1(LEN($B$1:$B$26)>0))*((1*ROW($B$1:$B$26)0,IF(ABS(A2-INDIRECT("A"&LARGE(IF((1*(LEN($B$1:$B$26)>0))ROW($B$1:$B$26)>0,(ROW($B$1:$B$26)=$K$1,ROW(A2),""),"")
ANOTHER EDIT: Instead, close this formula with ctrl+shift+enter in C2 cell and pull down till the last
=IF(B2<>"",IF(INDIRECT("B"&SMALL(IFERROR(IF(LEN(B3:$B$26)>0,ROW(B3:$B$26),""),""),1))<>B2,B2,""),"")
Third step - Arrange data in a list. This is what in your image is in columns D and E. Use these formulas in the first row of any column you want, and pull down as you wish since non utilized cells will just be blank
=IFERROR(SMALL($C$1:$C$26,ROW(C1)),"")
and
=IFERROR(INDEX($C$1:$C$26,E1),"")
EDIT: now use these formulas below to have the ordered list of changes
=IFERROR(SMALL(IF(LEN($C$1:$C$26)>0,ROW($C$1:$C$26),""),ROW(A1)),"")
and
=IFERROR(INDEX(C:C, F1),"")
As I've put the first of these two formulas on F1 (and pulled down), the second is using F1 as a parameter, but you can put any column you want, just don't forget to change in the index. The first of these two formulas also need to be closed with ctrl+shift+enter, the second doesn't.
This is how my sheet looks right now (with last changes)
OBS: Italic parts are "deprecated" in this answer. Only maintaining the text for "log" purposes.
The first of these two formulas use ROW() as a scapegoat for the number of SMALL's "K" parameter, so you pull down and it will return the first, the second, third, etc, trend changer rows. The other one will pull the matching "up" or "down" information.
OBS: since my Excel is in portuguese and I translated the functions to english using some web dictionary, I may have made some mistakes such as letting semicolon as parameter separators rather than commas. If something goes wrong please let me know and I'll try to fix it.
Related
I am tracking my days on duty and want excel to count the number of consecutive days on duty and post the totals next to the current date. I managed to insert a formula that does this but it counts in reverse order. In the attached image of the file note that on 6/13/2018 it shows 28 continuous days on duty. But that is counted from 7/10/2018 back. I want that 28 to show up on 7/10/2018. So that it counts from the previous days to the current day. Make sense????
What do I need to change in the formula to do this? Formula can be seen in the image.
Any suggestions would be appreciated
You need to build your formula the other way around:
If row r-1 has the same status as row r, then Counter_r should be Counter_(r-1) + 1. Otherwise, restart the counter - and Counter_r = 1
So, for example, in cell E3 the formula should be:
=IF(D3=D2, E2+1, 1)
I guess the picture helps a bit, but I would have preferred to see the data, even though this is simple enough to reproduce.
You probably want the formula:
=IF(AND(D2="On Duty",D2=D1),E1+1,1)
Starting in Cell E2 and copied down from there.
I've tried solving this problem on my own. However, I have yet to find an example or reference that fits to my particular situation.
I have the following Dataset:
However, since I cannot post more than two links, I cannot show the other sheets -- but they are equally similar.
They are single line items. (Also note, that my numbers are constantly changing in this case because I am using "=RANDBETWEEN(0,1000)". Do not focus on the numbers.
My Problem arises when I try to do my store analysis on my final page.
This is my problem:
STORE 1, JAN 16 : Electronics Cell "E4" is "Electronics!E5"
STORE 2, JAN 16 : Electronics Cell "E10" is "Electronics!E11"
When it should be "Electronics!E6"
This is just an example, my actual data has thousands of lines of data, otherwise I would just brute force this.
Any idea on what to do?
Thanks,
Calrabian
I would suggest to do a reference search with a VLOOKUP or MATCH function, instead of counting on locations alone.
For example, assuming your data is in Electronics!$C$1:$F$10, you can use an array formula in E4 and copy it to E11:
=INDEX(Electronics!$C$2:$F$10,MATCH($C4,Electronics!$A$2:$A$10,0),MATCH(E$3,Electronics!$C$1:$F$1,0))
*Use Ctrl + Shift + Enter to enter the formula as an array formula, and then copy to E11.
Explanation:
The main formula structure is INDEX(<data area>, <match Store row>, <match Date column>).
The INDEX function returns data in an array/reference according to a provided row and column indexes.
The MATCH functions find the index, horizontally or vertically.
The first MATCH($C4,Electronics!$A$2:$A$10,0) finds the Store row in the stores column A. C4 is the store name to find. You can play with this reference to suit your needs.
The second MATCH(E$3,Electronics!$C$1:$F$1,0) finds the Date column in the dates row 1.
You can make it more flexible and complex, but this is the general idea.
First off I must say your dates really bug me. Using yy-mmm for some and mmm-yy for others just throws me for a loop.
For an actual answer. Since you are not moving 1 cell at a time you will need to do some math to have a consistent formula all the way down.
First thing you need is to get a formula that returns the right row.
row 4 returns row 5
row 10 returns row 6
row 16 returns row 7 (assumption)
Use the function
=int((row()-4)/6)+4
Then insert it into an index function and you have your solution
=index(Electronics!E:E,int((row()-4)/6)+4)
EDIT *
A JAN FEB MAR APR
1<drpdwn> A1+JAN A1+FEB A1+MAR A1+APR
what i need is for B1 to hold a formula that will take A1+B as a string and use this as the name of a Table to grab a value from. so something like
=INDIRECT($A1&"B")[[#Totals],[Column7]] so the cell will display the value in column 7 in the totals row for a table that is named the result of '=INDIRECT($A1&"C")' =B2&A3 also works for creating the variable, but again. unable to use in the above formula
Hopefully this is a little bit clearer
As an example, I will have 12 tabs that lets say are months, JAN FEB MAR etc... these are the column headers in my above.
Within these will be various Tables, like Expenditure, income, etc... they will be named ExpenditureJAN, ExpenditureFEB.
I want a simple (overview) tab, that lets me select expenditure in A1, and each months columns will use the formula to display a value from its relevant table, so A(JAN) would display jan's expenditure total etc.....
=ExpenditureJAN[[#Totals],[Column7]] this would work, but i need the expenditure bit, to change to what ever is selected from a picklist in A1.
***Old Question - Before edit -
Didn't know how to word the question, but here is my problem;
I have tables called AB, AC, AD, BB, BC etc...
I want to look up the following =AB[[#Totals],[Column7]] which works fine. However.....
I want it to change AB to be the string created from two cells so for instance =A3&B2[[#Totals],[Column7]]
Hopefully that makes sense, i am struggling to put this into words for some reason.... To add to this, A3 will be a drop down list, so the idea is, i change the value in A3 and it will change the table each cell the formula is in to look at the correct value.
B C D E
# #B #C #D #E
So # can change via a picklist, and the formula will detect this change and fire off to look at #totals, column 7 in the table #B/#C etc.. using the column headers and picklist as references for the table name.*
As user3514930 stated you want to use the INDIRECT function. Given the following table:
A B C D E
1<drpdwn> #B #C #D #E
If Cell B1 contains the formula =INDIRECT($A1&"B") it would show whatever is selected in cell A1 immediately followed by the character B. So drag that over to fill the rest of the row and update the trailing letter to =INDIRECT($A1&"C"), =INDIRECT($A1&"D"), =INDIRECT($A1&"E") etc. in the formulas.
Then when the dropdown box in cell A1 is changed, say to C the table would look like this:
A B C D E
1 C CB CC CD CE
Edit: So I got this to work like you wanted using INDEX, INDIRECT, and an additional cell to reference the table desired. I setup a table like you suggested named ExpendituresJAN. It had 6 columns, first was Week1-Week4, then HR, IT, Admin, Sales, and Payroll for departments, and then Column7 where I had totals per week. I threw in some random numbers (IT had a heck a week 3, spending nearly $997k evidently, and the sales department outdid itself with it's end of month party running over $10k, but those boys do love to party!). Sorry, where was I? Oh yes, example table, I added a Totals row on, and went to trying to figure it out because INDIRECT really seemed to be the key and I just had to wrap my head around things.
Next sheet had basically 4 cells with anything in them. A2 had a dropdown where I could Choose JAN, FEB, or MAR. B1 said JAN (I imagine C1 would say FEB, but I didn't go that far). B2 said #REF! a lot of the time.
________| JAN
<drpdwn>| #REF!
In the end A2 was moved down to A3 for my dropdown box, and row 2 was hidden, I'll get to why that is in a second. Ok, how to reference that... I can't seem to do it traditionally with structured reference, which is a pain, but there's got to be a way around it. I crack my knuckles, pull up Chrome, and practice a little Google-fu. Turns out what we needed was INDEX, which will return a cell or range from a table by name. B2 (hidden now) now contains the formula ="Expenditures"&A3 which, when JAN was selected read ExpendituresJAN. Excellent, I'm pretty sure we're most of the way there now. I just have to phrase my INDEX right and I'm set.
So, INDEX ended up being relatively simple all in all, but there's a catch. No #Totals row accessibility for INDEX. I got hung up on that for a few minutes until I stepped back and thought "wait, what's my totals row except a =SUM() formula? Ok, I can duplicate that. INDEX works with this syntax: INDEX(array/table, Row#, Col#) but you can use 0 for the row and it takes the entire row into account. Perfect for what I want, since I want a sum of Column7, I'll just wrap the INDEX in a SUM function.
=SUM(INDEX(INDIRECT(B2),0,7))
That spits back $1,036,371.00, the exact same thing my totals row shows for Column7. The only complication I could see is if your different tables have different Totals rows, as in one does a SUM, one does an AVG, and what not. Then the formula starts getting a bit more complex.
How do I use conditional formatting to format only the last cell in each column with a minimum value ?
This implies a non-VBA solution.
I have tried using this formula, but it stops after first match (5 is formatted):
AND(A2>=5,COUNTIF($A$2:A2,">=5")=1)
Using this data, only 9 should be formatted.
Data:
1
2
3
4
5 <-- actual result
6
7
8
9 <-- expected result
UPDATE:
This formula seems to do the trick, but only works when the cell values in the range are numeric, which mine are, and only in 1 column. Range must match format area.
Note: I found the "INDEX..E+307" part somewhere else, but lost the URL so cant give credit.
AND(A2>=5,A2=INDEX($A$2:A10,MATCH(9.99999999999999E+307,$A$2:A10)))
A multi-column supported formula is now needed. Using OFFSET might be the way to go..
I'm reading the problem as this:
We want to highlight the last cell in the column, but only when the cells in that column contain at least one sufficiently large value.
Assuming data starts in A1, I came up with this:
=AND(COUNTIF(OFFSET(A$1,,,COUNT(A:A),1),">=5")>0,ROW()=COUNT(A:A))
There are some assumptions there: like we can say that the number of non-empty values can be counted by COUNTA(), or that data starts in row 1 so that we can find the last row with ROW()=COUNT(A:A). But hopefully you get the idea...
If you are in fact looking for the greatest value, not the last one, then this be a starting point:
AND(A2>=5,A2=MAX($A$2:A10))
That should work to locate the highest value across multiple columns as well. If your table can grow over time then you should look at defining the range with an OFFSET() formula.
Not sure this is even possible, but perhaps someone knows how to do it. I have a row with 6 columns (A-F). The first three columns are one set and the last three columns are a different set. I want to sum both sets and then find the difference between the sums. For example if the row is:
A1 A2 A3 A4 A5 A6
4 5 6 7 8 9
I want to add 4+5+6 and 7+8+9 and then find the difference between the two sums.
I think its something like this: =SUM(A1:A3)-SUM(A4:A6).
If you are only interested in the magnitude, you can put it in an absolute value: =ABS(SUM(A1:A3)-SUM(A4:A6)).
[edited to match revised post]
Also, now that I read your post more carefully, you also mention you want to add items within columns as well. In that case, its the same formula, except you change the letters, not the numbers: =SUM(A1:C1)-SUM(D1:F1).
In the spirit of the previous answer, it's
=SUM($A$1:$A$3)-SUM($A$4:$A$6)
Another solution is:
=$A$1+$A$2+$A$3-$A$4-$A$5-$A$6
The dollars aren't necessary, but if you build this formula using the mouse, you will get them and they don't matter.