Sounded so simple! I have a sheet called "Account", containing a running balance in column "G" and I have another sheet called "Performance", with a table which lists historical dates and column "D" needs to lookup the account balance on the day stated in column "A".
"Account" Sheet
"Performance" Sheet
For example, Performance!D2 should be "210,000.00".
Performance!D7 should be "110,000.00".
Performance!D9 would be "40,000.00".
To make this slightly more difficult I like to put formulas into the heading row as arrayformulas where possible, to avoid problems when copying and pasting data or adding new rows, etc.
I've tried many different possibilities and nothing has worked. I'm currently trying to make the following formula work, which is in Performance!D1.
=ARRAYFORMULA(if(row(D1:D) = 1, "Cash", VLOOKUP(A1:A, MIN('Balance'!A4:A <= A1:A), 7, 1)))
I've also tried some solutions involving MATCH(), FILTER(), VLOOKUP() and LOOKUP() but so far no cookie!
this should work:
=ARRAYFORMULA({"Cash";if(A2:A="",,VLOOKUP(A2:A, SORT('Account'!A4:G),7,TRUE))})
VLOOKUP(...,true) returns the value associated with the closest match in the first column without going over. Provided that the range into which you're doing the vlookup is sorted by the first column of that range.
Related
Hey Stack Overflow Sheets, I have a question regarding a use case we want to create in our Google Sheet, either with built-in functionality, or with an extension like Sheetgo.
We have 2 sheets with multiple of the same columns (properties) and rows (users). The problem is that only one of the sheets is a trusted source for one column’s data (“source sheet”), and the other sheet has empty or outdated values for the same column (“outdated sheet”), and we need both sheets to have this column match values in rows that have a matching value for another column across both sheets (in our case, an “email” column). After they’re matching, we want to change the formula to sync any changes made for that column between both sheets.
Here’s an obfuscated data example:
Source sheet:
https://docs.google.com/spreadsheets/d/1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o/edit?usp=sharing
Outdated sheet:
https://docs.google.com/spreadsheets/d/1ckoCh8gMwt2QeBRH1dB2dyFPJUukrjQ-SCgucTL8rhc/edit?usp=sharing
In the example, we’re looking for a formula that would allow us to have a “Type” column value injected into the Outdated Sheet’s Type column, based on both sheet’s matching Email column value. And then, have it so if a row’s “Type” value changes in either doc, the other doc follows.
What formula or extension would I use to go about this? Any help appreciated, thanks!
I tried to create a VLOOKUP and MATCH formula, but I couldn't yet figure out how to have the function first LOOKUP into the Source Sheet, then inject it into the Outdated Sheet based on a matched email column value. Sheetgo made the LOOKUP easier, but I still couldn't figure out how to do an exact operation.
Use importrange() and vlookup(). Put this formula in cell A1 of the target spreadsheet:
=arrayformula(
lambda(
import,
iferror(
vlookup(
C1:C,
{ index(import, 0, 3), index(import, 0, 1) },
2, false
)
)
)(
importrange("1uxqC3lB15UHhKTzjZyzzVIj5tlPjhCCCZ48xHYEcm0o", "Sheet1!A1:F")
)
)
I have a google sheet with multiple tabs, one of the tabs is for holding each observation of data while another needs to combine data based on certain criteria. I am trying to use a SUMIFS within and ARRAYFORMULA to get the correct information and it will only pull "0" no matter what I try.
I have set up a test google sheet with some dummy information to show an example of what I need to do in a more complex situation.
https://docs.google.com/spreadsheets/d/1JLyEuVijQ8MvfOKrtbRD_YKmRDnTCxf7qCSw9Ggty_Y/edit#gid=1250575550
In this example, the data tab is the individual observations and the sums tab is where I'm trying to pull combinations. I need column D to sum the totals in column E on the data tab if the Month and Year and Type all match what is on the sums sheet. In this example, cell D3 on the sums tab should equal 11.
you cannot use SUMIFS() in Arrayformula(), along with many other functions, though there is no formal documented list.
In your case you can use a SUMIF() instead by &'ing the condtions together.
I've demoed the concept on a new tab called MK_Help in cell D2:
=ARRAYFORMULA(IF(ROW(A2:A) = ROW(A2), "# TOTAL TYPE", IF(A2:A = "", , SUMIF(data!A:A&data!B:B&data!C:C,A2:A&B2:B&C2:C,data!E:E))))
Note that I made a couple of other small changes to your formula.
Namely, that you should always use a true "empty" instead of double quotes in your IF() mask up front tor return empty when there's no value in A. Double quotes("") is actually not quite empty for many other things in Google sheets.
Also I modified your header conndition from ROW(A2:A)=2 to ROW(A2:A) = ROW(A2). I find that this is a more flexible condition for the header as it allows you to potentially insert/delete rows above the header without breaking things.
It seems QUERY() may be good choice. Try-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A is not null group by A,B,C",1)
If you need specific month then you can add criteria to where clause like-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A =5 group by A,B,C",1)
I'm doing performance calculations on an America's Cup AC75 yacht, and have found Named Ranges very helpful in equations I use.
On a 'Data' sheet, I now have a lot of information that I'd like to reference as a Named Range, and use via VLOOKUP(), in my 'Analysis' sheet.
A problem I have struck is that if I need to Insert/Move a column in this new Named Range, the VLOOKUP function does not "update" the column that it should return.
For example, if a cell value is "=VLOOKUP(B6, Sail_Vectors, 10, false)", but I have to insert a new column before col 10 in the Named Range "Sail_Vectors", the desired column becomes col 11 - but the lookup still returns col 10, which is now incorrect.
I may be asking too much, but just wondering if anyone might have a work-around, or something I've overlooked?
If your sheet Data has headers, you can use them in order to reference your desired column dynamically, using MATCH:
=VLOOKUP(A1,Sail_Vectors,MATCH("Header C",Data!1:1),false)
Sheet Analysis:
Sheet Data:
I am looking for a formula that can perform the "COUNT" equivalent of "SUMIF". I have in 'Sheet A' running records of attendance, with column A as "Last Name," column B is "First Name," and column C is "Attendance." The attendance column has values of "P, A, L" for present, absent, or late (respectively). The sheet is automatically updated each day, as new data for the day's attendance are appended at the bottom of the sheet.
In 'Sheet B' I have each student's name, matching the syntax in the above sheet ("Last Name" "First Name"). In this sheet, I want to be able to count the number of instances of each, "P", "A", and "L".
So...I want to be able to count in Sheet A the number of times a student has a "A" in the attendance column, conditionally by student name. I know that with SUMIF you can sum a range conditionally. COUNTIF does not work to appropriately filter the values by the student name. I was not able to get DCOUNTA to work either.
Open to any suggestions, no matter how complex.
For anyone curious, I came up with my own crude solution.
I created a new sheet for each: Present, Absent Late. Within each sheet I ran a query: =QUERY({'Imported Data'!A:C}, "select * where Col3 = 'P'"). This query returned every record where an individual was marked "P". Repeat for "A" and "L" on their respective sheets.
In my main sheet, which records count totals, I used the COUNTIF: =COUNTIF(Present!D:D,C2). I had a small problem to work around in this, as I had my data imported with a "Last Name" and "First Name" column, but could not COUNTIF across two columns. So, I created an ARRAYFORMULA in each Present/Absent/Late sheet. This concatenated the name values, so I could search against that singular value in my main sheet. This was present in D:1 of Present/Absent/Late: =Arrayformula(A:A&", "&B:B).
A little duplication and I was able to create my own, automatically updated, attendance tracker.
You seem to have gone to a great deal of effort to work around a problem that does not exist. In general, where SUMIF works for adding then a very similar COUNTIF should work for counting. Because in most groups of modest size neither first names nor surnames are likely to be unique (even if the combinations are likely to be) it is generally a good idea to assign IDs to people. Concatenating Last Name with First Name is effective but other options can be more compact.
Assuming in Sheet B you have P, A and L respectively in C1:E1 (a unique set of Last Name in ColumnA and First Name in ColumnB) then in C2 the following may be adequate if copied across to E2 and C2:E2 down to suit:
=COUNTIFS('Sheet A'!$A:$A,$A2,'Sheet A'!$B:$B,$B2,'Sheet A'!$C:$C,C$1)
Sheets Imported Data and Present seem irrelevant.
My problem, generally stated:
I need a formula that returns all the values in a specific column for which multiple criteria in other columns of the respective row apply.
My problem, specifically stated:
I would like a formula that returns all the values in Column A for which Column C is "John", Column E is "Apples", Column G is "Earth" and both Columns H and I are empty. See here for a simplified illustration of my problem with dummy data. The correct formula, dragged down, would output a list with the values "1", "4", and "14". If you'd like to try out some stuff in the linked spreadsheet, feel free to do so in a copy of the original sheet so others can see my original data/formulas.
What I've tried so far:
Simply filtering was not an option because the data is on a separate sheet within the same spreadsheet. I also knew VLOOKUP and INDEX/MATCH were not going to do what I wanted - VLOOKUP doesn't handle multiple criteria, and while the MATCH part of INDEX/MATCH can be turned into an array to specify multiple criteria, it only returns the first value for which all conditions are true, while I need all of them.
I then tried the following formula (Formula 1 in the linked spreadsheet):
=IFERROR(INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1)),"")
It worked like a charm, until I wanted to include the condition that both columns H and I should be empty. I tried this, but for some reason I don't understand it didn't work (Formula 2 in the linked spreadsheet):
=IFERROR(INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G)*COUNTIF($K$5, $H$2:$H)*COUNTIF($K$6, $I$2:$I), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1)),"")
Then I tried to nest my first formula into an IF/VLOOKUP (Formula 3 in the linked spreadsheet):
=IFERROR(IF(VLOOKUP(INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1)),$A$2:I,8,FALSE)<>"","",INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1))),"")
This worked if I only asked for column H to be empty, but a) it is very unwieldy, b) it gives you blanks in the list it returns, which I do not want, and c) I could not get it to work for the condition that both columns H and I need to be empty using OR.
That's where I'm stuck, and I haven't come up with a good solution. Knowing this forum, I'm sure someone has an elegant solution I was not smart enough to find :)
I'm on phone so formating will suffer.
Create a new column on the left and insert the following into cell A2
=if(D2="John", if(F2="Apples", if(H2="Earth", if(I2="", if(J2="", B2,""), "" ), "" ), "" ), "")