How to assemble Offset function with Condition? - excel

I Have date data in Column A and values data in Column B.
My aim goal is that for each date in column A :
look if one value (column B) during 1 year is less than 90% of the corresponding Value of the date.
This is my data:
Output example :
I start at the first date (31/12/1986) and see the 900.82 value.
I calcul 900.82 * 0.9 = 810.73
So i look if value in line 3 is inferior to 810.73,
If not
I look if value in line 4 is inferior to 810.73,
line 5, 6, 7 ,8..... during 1 year (that mean I stop this the 31/12/1987).
If it is
I stop and i look the next date (01/01/1987) and do the same.
I am agree to translate it in VBA code, but it could be better on Excel.
I first tried an algo to understand the problem :
-Look the first date in column A
-Look the corresponding value in Column B and save it as Value
-Offset to the next date in column A
-Look the corresponding value in Column B and save it as Range.to.compare
-If Range.to.compare < Value * 90% then write "ok" in Column C
-Else, Offset to the next date in column A...
-Untill 1 Year (Untill Year(Date in Column A)<Year(Date in Column A) +1
I try to translate it in Excel or VBA.
This this what I tried by Excel :
But it works only for 1 day instead of 1 year

I think this is what you're after. I broke the calculation into multiple columns to show the steps.
First I calculate the 90% value, in column C.
Column D is where most of the magic happens. In column D I find all rows that have a date < the current date + 1 year, and get the value (Col B) for each of those rows. I then take the minimum of all those values. Note this is an array formula so you need to press shift-ctrl-enter after you type it in.
Now that I have the minimum from the each range, I just need to compare that with the 90% value.

Related

Number occurrences in another cell (Excell) [duplicate]

I have simple problem, but I've not be able to get an answer from searching. I require a column to calculate the number of the nth occurrence of a value. It's best explained in this picture
I require a method to calculate column B.
I'd be very grateful for any help.
Are you looking to merely provide a count of the distinct entries of column A in column B? Or merely add a formula to come up with the table in your link?
If the latter, then the formula to write in cell B2 is:
=COUNTIF(A$2:A2,A2)
then copy/paste it down column B. Note - if your data is both a Date and Time, but the cell is formatted to only display a date, you may not get the results you want. You'd need to interject a new column with a "floor" calculation to round the date/time value to a date (Excel date times are decimal, with integer part dictating the date, and remaining 0.0 -> 1.0 dictating the time of day)
If you just want to derive a table of the counts of distinct entries in column A, then a pivot table will do this for you - simple add a pivot table to cover the data in column A, then select column A into the rows category, and then also drag it into the values category, ensuring the field is set to "Count of". You should then have a table with the distinct entries in your data set in one column, and the count of their occurrences in the other column.
You can use the COUNTIF worksheet function, with a relative address.
Eg. In cell B2, enter this formula:
=COUNTIF(A$2:A2,A2)
And then fill-down.
Use the following formula to generate the required series:
=COUNTIF($A$1:A1,A1) and strech(copy) it in all the cells
This will generate result like this:
A 1 COUNTIF($A$1:A1,A1)
A 2 COUNTIF($A$1:A2,A2)
C 1 COUNTIF($A$1:A3,A3)
C 2 COUNTIF($A$1:A4,A4)
B 1 COUNTIF($A$1:A5,A5)
B 2 COUNTIF($A$1:A6,A6)
A 3 COUNTIF($A$1:A7,A7)
C 3 COUNTIF($A$1:A8,A8)
D 1 COUNTIF($A$1:A9,A9)
D 2 COUNTIF($A$1:A10,A10)
D 3 COUNTIF($A$1:A11,A11)
D 4 COUNTIF($A$1:A12,A12)

Auto Increment the value of a cell based on an adjacent sell value plus search last number increment by 1

Ok I have 2 excel columns
1st column A "Workstream", is a data list with three numbers as a dropdown. 1,2,3
2nd column B "ID", would like to auto-populate based on the selection made from the left adjacent cell + perform a lookup to get the MAX number in the current column and ADD by 1.
For Example:
Workstream
ID
1
W1-001
1
W1-002
1
W1-003
1
W1-004
2
W1-001
1
W1-005
2
W1-002
So when a user selects from the drop-down in column A then Column B auto-populates with something like this
="W"&A:1&"-"
However, in order to complete the value, it needs to do the following:
="W"&A:1&"-" Search for the Max Record in Column B that starts with 1 or whatever value was entered into Column A, then include the next number based on the MAX value selected in Column A
So in the above example, let's say I Enter "2" in column A, then the value that auto-populates in column B would be
| 2 | W2-003
or if I selected 1 from column A given where we left off then the value that would auto-populate in column B would be:
| 1 | W1-006
If I am understanding correctly and you want the format to be "W" followed by number of the workstream (as inferred from the text of your question) try:
="W"&A2&"-"&TEXT(COUNTIF(A$2:A2, B2), "000")
If instead you want the output exactly as shown in the picture you provided, it's even easier:
="W1-"&TEXT(COUNTIF(A$2:A2, B2), "000")
EDIT: You might consider pre-dragging the formula to all the rows that you think have the possibility of being impacted so that you don't have to drag the formula each time you add a row. In that case, try:
=IF(A2="","", "W"&A2&"-"&TEXT(COUNTIF(A$2:A2, B2), "000"))

Find an intersecting value for each row and column in excel

I have monthly data in rows in column A. I also have monthly data in headers from column B to Column G. In Column H i have current month populated for all rows. I would like to display the value where, for example if the month in row is Jan and current month is Mar, then find the value where Jan and Mar intersect and do this for all rows. I tried using the following formula in Column J but it only gives the first value when it works. The result in Column I is desired. Attached is the picture for clarity.
=INDEX(B1:H2,MATCH(A2,$A$1:A2,0),MATCH(A2,$B$1:H2,0))
You can do it with SUMPRODUCT.
I made a fake dataset with different values than the ones you show, so i could test properly if changing Current month would work.
It works even if column CurrentMonth holds different months
My formula is:
=SUMPRODUCT(--($B$1:$G$1=H2);B2:G2)
This is how it works:
--($B$1:$G$1=H2) will return an array of 1 and 0 if range B1:G1 is equal to current month in that row. So in case CurrentMonth=Mar then it will return {0;0;1;0;0;0}
With SUMPRODUCT we multiply previous array by range B:G in current row, so for row 2, it would be B2:G2. So as example, it would be {0;0;1;0;0;0} * {1;2;3;4;5;6} = {0;0;3;0;0;0} and we sum up this array, getting 3
just use INDEX with one MATCH:
=INDEX(B2:G2,,MATCH(H2,$B$1:$G$1,0))

excel extract 6 digits from number, format as date and match with index match?

I have the following 2 worksheets.
Data:
Column B Column C Column D COLUMN E Column F
329115121601 3291 5555 =Date (MID(B8,9,2),MID (B8,7,2),MID (B8,5,2)) 50 <---- Week Number from date
I am trying to extract 6 digits from my number value in Columb B '151216' and want to put this into column E. The 6 digits represent a date which is 15th December 2016.
I am using mid to try and get the number and then date to try and format this as 15/12/2016 - however it's not working. Instead I get 15/12/16.
On my other sheet, 'Home' i am trying to look up the number from column B on sheet 'Data' using an index match (array formula) where the values in column C, D and E or F match.
Home:
Column H Column I Column J Column K
3291 5555 15/12/2016 or Week 50 {=IFERROR(INDEX(Data!$B:$B,MATCH(1,(Home!$H10=Data!$C:$C)*(Home!$I10=Data!$D:$D)*(IF(Home!$J10<55,Home!$J10,WEEKNUM(Home!$J10))=Data!$F:$F),0)),"No Po Found")}
The user should be able to enter either week number or a specific date and get a result.
For some reason, this formula works if the user enters a week number, but not if they enter a specific date. I'm not sure if this is a format issue with the date on sheet 'data' or with the index match formula. Please can someone show me where I am going wrong? Thanks
Excel defaults to 1916 when I input your formula, try adding "20"& to the start of the year parameter:
=Date("20"&MID(B8,9,2),MID(B8,7,2),MID(B8,5,2))
I think you are doing it well. Just need to format the date.
Right click on the cell that contains the date ( 15/12/16 ) then click on cell formatting option and choose the format you prefer.

Calculate Occurrence Number - Excel

I have simple problem, but I've not be able to get an answer from searching. I require a column to calculate the number of the nth occurrence of a value. It's best explained in this picture
I require a method to calculate column B.
I'd be very grateful for any help.
Are you looking to merely provide a count of the distinct entries of column A in column B? Or merely add a formula to come up with the table in your link?
If the latter, then the formula to write in cell B2 is:
=COUNTIF(A$2:A2,A2)
then copy/paste it down column B. Note - if your data is both a Date and Time, but the cell is formatted to only display a date, you may not get the results you want. You'd need to interject a new column with a "floor" calculation to round the date/time value to a date (Excel date times are decimal, with integer part dictating the date, and remaining 0.0 -> 1.0 dictating the time of day)
If you just want to derive a table of the counts of distinct entries in column A, then a pivot table will do this for you - simple add a pivot table to cover the data in column A, then select column A into the rows category, and then also drag it into the values category, ensuring the field is set to "Count of". You should then have a table with the distinct entries in your data set in one column, and the count of their occurrences in the other column.
You can use the COUNTIF worksheet function, with a relative address.
Eg. In cell B2, enter this formula:
=COUNTIF(A$2:A2,A2)
And then fill-down.
Use the following formula to generate the required series:
=COUNTIF($A$1:A1,A1) and strech(copy) it in all the cells
This will generate result like this:
A 1 COUNTIF($A$1:A1,A1)
A 2 COUNTIF($A$1:A2,A2)
C 1 COUNTIF($A$1:A3,A3)
C 2 COUNTIF($A$1:A4,A4)
B 1 COUNTIF($A$1:A5,A5)
B 2 COUNTIF($A$1:A6,A6)
A 3 COUNTIF($A$1:A7,A7)
C 3 COUNTIF($A$1:A8,A8)
D 1 COUNTIF($A$1:A9,A9)
D 2 COUNTIF($A$1:A10,A10)
D 3 COUNTIF($A$1:A11,A11)
D 4 COUNTIF($A$1:A12,A12)

Resources