Vlookup to check two conditions - excel

I am referring to below my google spreadsheet
https://docs.google.com/spreadsheets/d/1dCfShenhV2j98q5wkOXMeyWj9tlMZbaBgBqB2vAPdHo/edit?usp=sharing
I am looking to update H,I and J columns using vlook formula in way that it should match both name and date values in my data range, which in A,B and C columns
Here is the issue I am facing with normal vlookup is that I can check only name.It is ignoring the date and updating the vlooked up data on all date column.
Eg: Alpha and date 20141120 value is 10, it should fill only H3, but it is updating, H3 I3 and J3 with value 10
I really appreciate your answer on this problem!!!

you can use this formula of index and match:
=IFERROR(INDEX($A:$C,MATCH(1,($A:$A=$G3)*($B:$B=H$2),0),3),"")
paste it in the first cell of your table H3, and drag and fill to the right and then select the entire row and fill down till end.
it should work.
if error(();"") : you will get empty cells if there is no match.
this is an array formula, so press ctrl+shift+enter to calculate the formula
UPDATE: here is [the example sheet downloadable from here}(https://www.dropbox.com/s/clqxsj5j4bdk27b/indexmatch.xlsx?dl=0)

Basically you need to concatenate the results, then use a VLOOKUP on that.
I.e. insert a column between B and C, with formula "=CONCATENATE(A2,B2)"
In the range you want to update, use the column and row headings for you lookup
"=VLOOKUP(CONCATENATE($g3,h$2),$c$1:$d$3,2,false)"

You want to perform a Multiple Lookup (see this).
As indicated there, enter
=IFERROR(LOOKUP(2,1/($A$1:$A$3=$G3)/($B$1:$B$3=H$2),$C$1:$C$3),"")
in H3. Copy into H3:J5.
This avoids array formulas.

Related

Check if a row contains a negative value, if so, insert that cells first row in specific column

I am trying to figure out something I am not sure can be done with formula's alone (hence the tag of VBA as I am open to VBA-related answers).
As you can see in the screenshot below, I have a column I, in cell I2 (and from I2 onwards, I3, I4 etc) I want to check that cells row (I2 -> J2, K2, L2 etc) and when I find the first negative value, the formula inserts that specific cells first row in that column, in this case, the date of that column.
I am currently using the following formula: =IF(COUNTIF(J2:BJ2,"<0"),"Yes","No")
However, I was not sure how to insert the first negative values date, as you can seen in the next screenshot.
I would like my data to look like the following:
Anyone got any ideas? or is this a VBA task?
INDEX/MATCH will do the trick. Wrap it in IFERROR to return the "No" result.
INDEX($J$1:$M$1,MATCH(TRUE,INDEX(J2:M2<0,),0))

How to Sum Daily Totals in Column?

What I'd like is to have a fill down formula that looks to see when the date value changes, and sum all the previous rows for that specific date.
For example, here's a spreadsheet:
In column J, you'll see that those values are the sums of each day. Those sums should only be displayed when the date changes, and the sums will just be the sums of each specific day. I think this has to require an array formula of some kind, but any suggestions? Thanks!
UPDATE
#Scott
I should mention that the dates aren't always the same length, meaning there could have been 2 rows on one date, and 6 on another date. They are sorted, but different number of rows. So it needs to also look backwards to see where the dates change as well...
I've used the formula provided in column K, and then filled it down. The expected answer is in the column just to the right of that.
Moving my comment to an answer because I believe this works, assuming your data is sorted by date, as Scott notes:
=IF(B2<>B3, SUMIF(B:B, B2, I:I), "")
This says if the next date is not equal to the current date, sum all values for that date. Otherwise leave the cell blank.
Edit: just noting for clarity based on the comments, the formula with the given row references assumes the table in question has a 1 row header, and the formula is written in row 2 and filled down. For this question the formula goes in J2 and is filled down. Also note that if you choose to reference a specific cell range instead of entire columns with B:B and I:I, the row references need to be anchored so they don't move when filled down, for example: =IF(B2<>B3, SUMIF(B$1:B$100, B2, I$1:I$100), "")
Update #OP was looking for a forumla based approach.
Well, if the dates are sorted then it can be done with following formula in row 2 beside the Net Units column.
=IF(B2<>B3, SUMIF ($B$2:$I$50, B2, $I$2:$I$50), "")
The row numbers and columns letter should be changed to reflect the data to be selected. Missing the $ (absolute reference) will break the formula.
sumif (range, criteria, sum_range)
// Range is you area from criteria column till the sum_range column, and sum_range is the column that has numerical value to be added.
This kind of problem is best solved by using Pivot Tables. Select your data, make sure each column name/field is unique and then proceed as follows:
Go to Menu > Insert > Pivot Table
Select the cells or worksheet (new worksheet preferred) where you want the Pivot Table to be created.
In the PivotTable builder select, your Date column to Rows
Select the columns that you want to be summed up and drag to the Values Filed
Adjust the Value Filed Settings (in the Values Field list (click the drop down arrow next to each field) to SUM function. [if needed]
Viola! This should produce the desired outcome and should be the preferred method.

Excel or pentaho formula to get sum of distinct values in a column

I want to add a formula in penthao report to get sum of distinct values in a column. The formula of penatho is similar to excel. So how do i do that in excel. Please help.
I'm not sure if this can be done in a single cell, but it certainly is possible by adding in an extra column. For instance, if your range is A1:A25, you can type this formula in Cell B1 and drag it down to cell B25:
=IF(COUNTIFS(OFFSET($A$1,0,0,ROW(),1),$A1)=1,1,0)
This formula enters a 1 if the value in the range is the first occurrence, and 0 otherwise. The last step is to use a simple sumproduct for the final result:
=SUMPRODUCT($A$1:$A$25,$B$1:$B$25)

excel SUMIFS only on same date

I'm trying to create a formula in column K which sums all cells that apply , in column J, only when the following conditions are true:
dates are the same in column A
AND client name is the same in column B
For example, in cell K2, I want the sum of J2+J3+J4 because A2=A3=A4 and B2=B3=B4.
K5=J5 only, because there are no other dates with the same client name.
K6=J6+J7 because A6=A7 and B6=B7.
What kind of formula would I use for this? I can't figure out how to do it with a SUMIFS.
I would try using a pivot table with:
The names as row values
The dates as the column values
And funds received using SUM in the values column
Edit
Based on #pnuts comments here is how to get the values in column K. Put this in K2 and drag down.
=IF(OR(COUNTIFS($B$1:B3, B3) = 1, B3 = ""), SUMIFS($J$2:J2, $A$2:A2, A2, $B$2:B2, B2), "")
This formula will give blank values until the formula finds a new client on a new date. However, I still think using pivot table is a better solution.
However, I still find the pivot table
In cell K2 put following formula:
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,SUMIFS($J$2:$J$10,$A$2:$A$10,A2,$B$2:$B$10,B2),"")
Adjust row 10 value. It will be last row of your actual data.
Copy down as much you need.
EDIT
Uploaded file shows the cause behind formula not working correctly for you. It turned out to be whitespace characters in column B (names) data e.g.
Cell B3: "Moe John" has a trailing space.
Cell B10: Same case with "Doe Jane"
If you want to use above posted formula then all names shall be corrected. Or alternatively to deal with spaces you can adopt below approach.
=IF(COUNTIFS($A$2:A2,A2,$B$2:B2,"*"&TRIM(B2)&"*")=1,SUMIFS($J$2:$J$28,$A$2:$A$28,A2,$B$2:$B$28,B2),"")
Notice the change in COUNTIFS formula where B2 is now replaced with "*"&TRIM(B2)&"*".
Even such formula will take a beating if you have uneven whitespace characters in between your data. I'd suggest normalizing it as much as possible.

Trying to import cell data based on cell drop down

I'm trying to re-do a spreadsheet.. Without having to put an =if into every cell where the data would be variable depending on the selection of a drop down (Which is how it is set currently :( )
On the main sheet.. Cell J1 i have a dropdown selection.. And im looking for the cells in
A1-F1 to be populated with the information on the data sheet.. Based on the selection either 1 or 2 in this example but i cant figure out how to do this
Any help would be appreciated
This is what VLOOKUP functions are for. VLOOKUP functions search for a key in the first column of a range, and matches the selected row on it.
You can just put =J1 into your A1 cell, and on your B1 cell you can search for A1 as =VLOOKUP($A1,Data!$A$1:$F$2,2,FALSE). This formula can be read like this:
"Please, search for the value that it's in $A1 in table Data!$A$1:$F$2.When you got it, get me the column 2. Ah, by the way, if you asked me if the key column is made of sorted numbers, so if you can't find it, you can extrapolate linearly, I'd answer FALSE, got it? Thanks a bunch!"
So, in your C1 cell you'd ask for the column 3, and so on. Of course, if you'd like to just create a single formula, you can insert a row over your row 1, and put the column references over the cells, as this:
In this case, my formula on B1 is =VLOOKUP($A2,Data!$A$1:$F$2,B1,FALSE) - which can be dragged to C1:F1. Of course you can later hide the row 1 from your user.
Hope that helps.

Resources