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

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.

Related

How to calculate Client Repeat Rate? (If any row in a column containing a name corresponds to a particular value then....)

I have a list of deals (usually unsorted) and I'm trying to find out if a company is a new client or a repeat client for each year (2019, 2020, & 2021).
The data is present as follows:
Company
Year
Company 1
2019
Company 2
2019
Company 2
2020
Company 2
2020
Company 3
2020
Company 3
2020
Company 2
2021
Company 4
2021
I need it to be calculated as:
Company
2019
2020
2021
Company 1
New
Lost
Lost
Company 2
New
Repeat
Repeat
Company 3
-
New
Lost
Company 4
-
-
New
I've created the desired outcome by creating a couple of helper columns, but how do I get the outcome without those? You can view the current work here: https://docs.google.com/spreadsheets/d/1jRTb1X4mFpLqyqADayqame-jWe2LoFizmARc7OCF424/edit#gid=1425919264
Struggling with using INDEX MATCH or VLOOKUP, specifically -> If [Company Name] is first signed in 2019, and any row in Column A containing [Company Name] corresponds to 2020, then [Company Name] is "Repeat" else....
Any help is appreciated.
In legacy Excel, this must be entered as an array formula
In Google sheets (assuming the same cell references) then the array aspect must also be made explicit, i.e.
=ARRAYFORMULA(IF(ISNA(MATCH($D2&E$1,$A$2:$A$9&$B$2:$B$9,0)),IF(OR(D2="New",D2="Lost"),"Lost","-"),IF(OR(D2="New",D2="Repeat"),"Repeat","New")))
Filter is Your Friend
On a separate sheet, in cell A1 as a heading lets place the word company and in B1 lets place status.
Now in cell A2 place =UNIQUE('Your Sheet Name'A2:A) to get a unique list of company names. Assuming your company names are on column A and start on the second row.
Before the next part, lets place the year somewhere in the sheet. Lets do in cell D1 and to the left in cell C1 lets type in "Year" for clarification.
Now in cell B2:B1000 put =IF(A2 = "", ,IF(INDEX(SORT(FILTER(Sheet1!$A$2:$B,Sheet1!$A$2:$A = A2),2,FALSE),1,2) >= $D$1,IF(COUNTIF(Sheet1!$A$2:$A,A2) > 1,"Recurring","New"),"Lost"))
We basically are saying If the cell to the left of this formula is not blank and the most recent entry is greater than or equal to the year I placed in D1 then I want to see if this is the first time we have this company in our dataset
If it is, then it would be new development, if not then it would be recurring. And if the most recent entry for this company is not greater than or equal to the year in D1 then it was lost.
grouped deals can be done like:
=INDEX(1*QUERY(A3:C, "select count(A) where A is not null group by A pivot C"))
and status like:
=ARRAYFORMULA(QUERY(IF(ISNUMBER(
QUERY(A3:C, "select count(A) where A is not null group by A pivot C"))*1=0, "lost", IF(ISNUMBER(
QUERY(A3:C, "select count(A) where A is not null group by A pivot C"))*1>ISNUMBER(
QUERY(A3:C, "select A,count(A) where A is not null group by A pivot C"))*1, "new", "repeat")), "offset 1", ))

How to create different date ranges based on criteria?

I have a table with two active columns. In Column A I have all the dates between, let`s say, January 1, 2012 to December 31, 2019. In column B I have a corresponding name. For instance:
[
etc.
I want to create ranges based on criteria, like:
The trick is, this should be done by calendar year, which means that during the 8-year period, I should have 8 set of 3 columns (from / to / name), one for each calendar year. If one range covers two years (let's say, November 1, 2012 to February 1st, 2013), the last row of 2012 should read
2012-11-01 to 2012-12-31
while the first row of 2013 will read
2013-01-01 to 2013-02-01
I managed to separate the ranges, but for some reason I am not able to go further and do that for each calendar year. Is there a way to do that?
Let's assume you want to place your 8 set of 3 columns starting from column G and that your list in the range D:F has headers in row 1 and data from row 2 on. In cell G1 write down your first year (2012), in cell H1 "From", in cell I1 "To" and in cell J1 "Name".
Now in cell H2 write this formula:
=IF(IF(OR(IF(AND($E2>=DATE(G$1,1,1),$D2<=DATE(G$1,12,31)),1,0),IF(AND($D2>=DATE(G$1,1,1),$E2<=DATE(G$1,12,31)),1,0)),1,0),MAX($D2,DATE(G$1,1,1)),"")
In cell I2 write this formula:
=IF(IF(OR(IF(AND($E2>=DATE(G$1,1,1),$D2<=DATE(G$1,12,31)),1,0),IF(AND($D2>=DATE(G$1,1,1),$E2<=DATE(G$1,12,31)),1,0)),1,0),MIN($E2,DATE(G$1,12,31)),"")
In cell J2 write this formula:
=IF(AND(H2<>"",I2<>""),F2,"")
Drag the 3 of them all the way down accordingly to your need. You can then copy the G:J range and paste any time you need next to itself; just change the year in the top left cell and it should do the trick.
Report any question you have or bug you have encountered. If, according to your judgment, this answer (or any other) is the best solution to your problem you have the privilege to accept it (link).

Excel SUMPRODUCT with dynamic column range to sum

A B C D
1 Department Jan Feb Mar
2 Marketing 100 200 300
3 R&D 150 250 350
4 Marketing 300 400 500
I have a sample file like the above table.
The SUMPRODUCT formula below only sums the specific rows and column, which is row 2 to 20 and column B to C for summing
=SUMPRODUCT((A2:A20="Marketing")*(B2:C20))
Actual formula (from comments):
=SUMPRODUCT(INDEX(BW!$A$3:$AE$3,MATCH(C$35,BW!$1:$1,0)+MATCH("JAN 2016",BW!$F$2:$R$2,0)-1):INDEX(BW!$A$108:$AE$108,MATCH(C$35,BW!$1:$1,0)+MATCH("A‌​UG 2016",BW!$F$2:$R$2,0)-1)*(BW!$B$3:$B$108=$E$1))
My questions, is there a way to make SUMPRODUCT dynamic, in a sense, it knows the first row to take will be 2nd and ends at 20.
As for the dynamic column to sum, it'll depend on the criteria. i.e. if the criteria is Feb and Mar, it'll take column C2:D20...again, the row is dynamic as well.
If you turn your range into a table called Table1 then the following should work:
=SUMPRODUCT((Table1[Department]="Marketing")*(INDIRECT("Table1[[Jan]:["&VLOOKUP("*",Table1[#Headers],COLUMNS(Table1),FALSE)&"]]")))
To make the SUMPRODUCT dynamic we can use INDEX/MATCH to find the extents of the data.
Then all that is need is to put the months wanted listed in one cell, I used I7
=SUMPRODUCT((ISNUMBER(SEARCH($B$1:INDEX(1:1,MATCH("ZZZ",1:1)),I7)))*($A$2:INDEX(A:A,MATCH("ZZZ",A:A))="Marketing")*B2:INDEX(A:DD,MATCH("ZZZ",A:A),MATCH("ZZZ",1:1)))
The INDEX(A:A,MATCH("ZZZ",A:A)) will find the last cell with text in Column A, and use that to set the extent of the dataset.
For the Last column we use INDEX(1:1,MATCH("ZZZ",1:1))
If you are not going to work with a ListObject (aka Structured) table, then a dynamic named range would certainly help.
Go to Formulas, Defined Names, Name Manager and when the Name Manager dialog opens, click New.
Give your defined name range a unique name; I've chosen Departments.
Leave the Scope as workbook and use the following formula for the Refers to:  =BW!$A$1:INDEX(BW!$A:$M, MATCH("zzz",BW!$A:$A ), MATCH(1E+99,BW!$1:$1 )) Columns A:M will cover a Department column and Jan through Dec. Note that Jan 2016-Dec 2016 are real dates (e.g. 1/1/2016 to 12/1/2016) formatted as mmm yyyy.
You should end up with the following dynamic named range:
Now you can 'shape' the sections of the defined range using INDEX/MATCH function pairs.
=SUMPRODUCT((INDEX(Departments, 0, 1)=Q3)*
(INDEX(Departments, 0, MATCH(R3, INDEX(Departments, 1, 0), 0)):
INDEX(Departments, 0, MATCH(S3, INDEX(Departments, 1, 0), 0))))

Excel: Transpose data from rows to column headings

My problem, as the title states, has to do with transposing data from rows to columns
The original data came into a csv format where in the second column 'Dates and Rank' semicolons and spaces acted as delimiters.
Country Dates and Rank
Switzerland [2014-03-07] 7;[2014-10-17] 7;
USA [2011-07-01] 7;[2012-02-17] 7;[2012-09-30] 7;[2013-01-31] 7;
France [2011-07-01] 4;[2012-02-17] 4;[2012-09-30] 4;
China [2015-01-16] 7;[2015-03-06] 7;[2015-10-16] 7;[2015-10-23] 7;
So, by using the Text to Columns function from excel I separated the data within 'Dates and Rank' column into different cells. And now the result looks like this:
Country Dates and Rank C D E F G H I
Switzerland [2014-03-07] 7 [2014-10-17] 7
USA [2011-07-01] 7 [2012-02-17] 7 [2012-09-30] 7 [2013-01-31] 7
France [2011-07-01] 4 [2012-02-17] 4 [2012-09-30] 4
China [2015-01-16] 7 [2015-03-06] 7 [2015-10-16] 7 [2015-10-23] 7
*I have also deleted the square brackets from the dates and I assigned them as YMD cells.
But what I need to do now is to use the dates as headings while I use the rank (1-7) as their allocated data within the cells. For example:
Country 2011-07-01 2012-02-17 2014-03-07 2014-10-17
Switzerland 6 7
USA 5 7
Any suggestions please?
Thank you.
I'll assume your data starts in cell A1 (i.e. A1 contains "Country").
First, create a new worksheet where your newly ordered data will come. You first need to fill in the column header row. You can do this by
manually copy-pasting all the date columns from your original data to a single column in the new worksheet, so that all dates are in one column
Remove duplicates (in the ribbon: Data > Data Tools > Remove Duplicates)
Sort the list if you want (Data > Sort & Filter > Sort)
Select the resulting data, copy, and transpose-paste in cell B1 (Home > Paste > Paste Special, and check the box "transpose"). Now you can also remove the data you just copied.
Second, copy-paste column A of the source worksheet into column A of the destination worksheet.
Finally, for each country and each date you want to look up the data right next to the date. You can do this by using the following formula in B2:
= IFERROR( INDEX( Sheet1!2:2, 1, MATCH( B$1, Sheet1!2:2, 0 ) + 1 ), "" )
Finally, copy this formula down and across.
This should do the trick just fine, but it is not a very flexible solution and you need to follow the steps exactly as explained. For example, if the countries are in a different order than they are in your original data sheet, it won't work.

Excel Index Partial match

I have Sheet1 with column A listing every single country in alphabetical order..
A
1 Afghanistan<
2 Albania
3 Algeria
4 American Samoa
5 Andorra
----------
228 United Kingdom
229 United States
etc
I have Sheet2 column A with empty cells with adjacent cells in column B listing address details
A B
1 empty cell Unit 3, Road;London, United Kingdom
2 empty cell Building 1, Road, TX, United States
3 empty cell 8th floor, Business Park, India 1234
etc
What I would like to know is how can I obtain the country within the address details in sheet2 column B and place them in Sheet2 column A, based on a match on the list of countries in Sheet1 column A.
Part of the problem is there is no coherent method as to how to country is placed within the address; could be at the end or in the middle of the address.
I have tried various index match formulas with no luck
any help would be appreciated.
I tried it with the reference table being in A1:B7, and lookups being A10:B10 onwards down. The formula is for these cells. You can adjust it for Sheet1/2!.
Assuming your data is in B10 onwards, and your reference data was in B1:B7, you can write this formula in A10 =INDEX($B$1:$B$7,MAX(IF(ISERROR(FIND($B$1:$B$7,B10)),-1,1)*(ROW($B$1:$B$7)-ROW($B$1)+1))). This is an array formula, so please hit Ctrl+Shift+Enter for excel to read it as an array formula.
(In the screenshot, I have pasted the table in A10:B12 as values only in D10:E12)
Text to Columns with a comma delimiter

Resources