Excel, finding the highest date value from a list with duplicate values - excel

I have a deep column A with IDs and each ID has in next column B date value.
Problem is that A contains up to 4 duplicate values at different places, thus e.g. 25430 could be there 4 times with different dates, e.g. 1.1.2014, 3.2.2015 etc.
I`d need to get into column C sorted column A - only 1 unique ID and if there are duplicate IDs in A then pick the highes date value.
Of course I could do it manually by sorting A by duplicate IDs and then manually delete other IDs with lower date but it`s not realistic to do it this way..
Thanks ;)

To identify the highest date value in ColumnB associated with each of the unique values in a labelled list in ColumnA:
=MAX(IF(A:A=A2,B:B))=B2
enter with Ctrl+Shift+Enter and copy down to suit.

So I was able to do this with the following formula if you have this data:
A B
Date Rank
01/01/2015
01/01/2015
01/01/2015
02/02/2015
01/01/2014
03/03/2015
04/04/2015
04/04/2015
03/03/2015
04/04/4015
So in B2, you should put the following code:
=SUM(1*(A2>$A$2:$A$11))+1+IF(ROW(A2)-ROW($A$2)=0,0,SUM(1*(A2=OFFSET($A$2,0,0,INDEX(ROW(A2)-ROW($A$2)+1,1)-1,1))))
then CTRL+SHIFT+ENTER which will turn it into an array and drag it down, this is what you will end up with:
Date Rank
01/01/2015 2
01/01/2015 3
01/01/2015 4
02/02/2015 5
01/01/2014 1
03/03/2015 6
04/04/2015 8
04/04/2015 9
03/03/2015 7
04/04/4015 10
1 Being the earliest date and 10 being the latest date.
I hope this helps :)

Related

Subtotals in a column based on ranges in another column

Consider a table like the following:
WEEKNUM HOURS WEEKTOTAL
==============================
1 2
1 4 6
2 3
2 5
2 1 9
3 6 6
... ... ...
I am searching for a formula to use in the WEEKTOTAL column that sums those entries in the HOURS column that share the same weeknumber. I would like the actual subtotal entry to be added in the row that contains the last occurrence of each weeknumber (the entries are likely sorted by weeknumber). The other cells in this column can be empty.
I'm hoping this is possible using an ARRAYFORMULA, but I am not sure how to.
Thank you in advance!
Assuming "WEEKTOTAL" cell is C1.
in C2 :
=IF(A2<>A3,SUM(OFFSET(B2,0,0,-1*COUNTIF(A:A,A2))),"")
and drag downwards.
Idea : use countif() to 'drive' offset() range. Which in turn will be the range for sum(). All only happens if the next column a value is different (IF(A2<>A3, .. ) ).
Pls share if it works/not/understandable.

Excel function to Auto-Populate value in Column C based on the combination of values in column A and Column B

I have 3 columns with values filled in already in my metasheet. A combination of values in column A and column B makes the selection unique. I need to pull/return the value in column C for the values selected in columns A & B. for example: In sheet 1, I have the following data:
country Month weather
1 USA Jan winter
2 USA Feb fall
3 USA May summer
4 China Jan summer
5 China Feb spring
6 China May fall
7 India Jan fall
8 India Feb summer
9 India May Rain
Now, say for a random row 25, I have A25 as a dropdown list with value selected ="India" and B25 as a dropdown list with value selected="Feb", in which case I would want C25 to have a dropdown list with the value in it being "Summer".
I tried this formula:
=VLOOKUP(B25, OFFSET(B$1:C$9, MATCH(A25,A$1:A$9,0)-1, 0, 2, 2), 2, 0)
But this one gives me an error: "The list source must be a delimited list, or a reference to a single row or column".
I did refer to this solution. But I get the above mentioned error as the data validation for C25 is a list.
Any suggestions/ideas on this would be helpful!
Thank you!
If your sheet is set-up like this:
You can use:
=INDEX(C2:C10,INDEX(MATCH(1,(A2:A10=E2)*(B2:B10=F2),0),0))
You will need to make a second sheet with a matrix like following -
Here you will define all the weathers for country and month pair. I have used the default name i.e. Sheet2 and filled the values that were available from your data. You will lookup the values from this for filling on Sheet1. Sheet1 will be like this -
=VLOOKUP(B2,Sheet2!$A$1:$D$13, MATCH(A2, Sheet2!$A$1:$D$1, 0), FALSE)
Here B2 is the month value, A2 is the country value. Sheet2!$A$1:$D$13 is the range for VLOOKUP and Sheet2!$A$1:$D$1 is the range for MATCH. VLOOKUP will match the month, MATCH will match the country and get the column index.

Getting the next higher value with VLOOKUP or INDEX/MATCH

I have the following Excel spreadsheet:
A B C D
1 0 Product 1 7.500 Product 4
2 1.000 Product 2
3 5.000 Product 3
4 10.000 Product 4
5
In Cell C1 I type a random number (in this case 7.500). Now I want that in Cell D1 the corresponding Product is shown to the value in Cell C1. Since 7.500 does not exist in Column A the next higher value should be used. In this case 10.000 which belongs to Product 4.
I tried to go with the following formula in Cell D2 but instead of getting Product 4 I get #NV as a result.
=INDEX(A1:B4;MATCH(C1;A1:A4;-1);2)
The only solution I found so far was changing the values in Column A from ascending to descending. However, I would prefer to have a solution which does not require a change of the order in the list.
Do you have any idea how to solve this issue without changing the order in the list?
For unsorted data you can use below formula::
=INDEX(B1:B4,MATCH(SMALL($A$1:$A$4,COUNTIF($A$1:$A$4,"<"&C1)+1),A1:A4,0))
See image for reference

Getting the next lower value with VLOOKUP

I have the following Excel spreadsheet:
A B C D
1 15.000 Product 1 7.500 Product 2
2 5.000 Product 2
3 1.000 Product 3
4 0 Product 4
5
In Cell C1 I type a random number (in this case 7.500). Now I want that in Cell D1 the corresponding Product is shown to the value in Cell C1.
Since 7.500 does not exist in Column A the next lower value should be used.
In this case 5.000 which belongs to Product 2.
I tried to go with the following formulas in Cell D2 but instead of getting Product 2 I always get Product 4 as a result.
=VLOOKUP(F16,$A$1:$B$4,2,TRUE)
=VLOOKUP(F16,$A$1:$B$4,2)
Do you have any idea how to solve this issue?
For unsorted data you can use below formula:
=INDEX(B1:B4,MATCH(LARGE($A$1:$A$4,COUNTIF($A$1:$A$4,">"&C1)+1),A1:A4,0))
See image for reference
i will try it with addition columns, which indicates the difference between given 7.5 and col A like this: =IF($C$1-A1<0,999999,$C$1-A1) and then get the mininum value like =MIN(E1:E4). then get the according value in column B.
If the order is not guaranteed to be ascending then you can use an array formula (use ctrl+shift+enter instead of just enter to create an array formula)
=INDEX(B2:B5,MATCH((C2-MIN(IF((C2-A2:A5)<0,MAX(A2:A5),C2-A2:A5))),A2:A5,0))

How do I match a date from a list of dates in Excel?

I need to compare two dates to see if they are equal from a list of dates in a column.
Eg. Sheet 1 Column A
Date 1
Date 2
Date 3
Date 4
Sheet 2 : Row F: Date 5
I want to see if date 5 is equal to any of the dates in column A and return true.
Please help me with this.
An alternative approach:
Assume Date1-Date4 are in A2:A5, and Date5 is in B2:
{=OR(B2=A2:A5)}
Note that you need to enter the formula as an array formula using Ctrl+Shift+Enter.

Resources