I have one table like this:
SHORT TERM BORROWING
1/6/2009 94304
12/31/2010 177823
6/30/2011 84188
12/31/2011 232144
6/30/2012 94467
9/30/2012 91445
12/31/2012 128523
3/31/2013 83731
6/30/2013 78330
9/30/2013 70936
12/31/2013 104020
3/31/2014 62345
6/30/2014 62167
9/30/2014 63494
12/31/2014 104239
3/31/2015 69056
I have another column which lists each date from 2009 to 2015 in chronological order, like:
1/2/2009
1/3/2009
1/4/2009
1/5/2009
1/6/2009
1/7/2009
1/8/2009
1/9/2009
1/10/2009
1/11/2009
1/12/2009
1/13/2009
1/14/2009
1/15/2009
1/16/2009
1/17/2009
1/18/2009
1/19/2009
1/20/2009
1/21/2009
1/22/2009
1/23/2009
1/24/2009
1/25/2009
...
6/22/2015
I am trying to write a function that will take the values from the first table, and match them to their corresponding dates in the chronological dates column. Basically, I want the second column, which lists each date in chronological order, to have a value of "94304" for "1/6/2009", and then blanks until it reaches 12/31/2010, where it should have a value of 177823, and so on until 6/22/2015. I have tried using VLOOKUPs but no luck so far. What is the appropriate function?
If data in your first table starts at A2, and your other column starts at D2, then use in E2
=VLOOKUP(D2,$A$2:$B$17,2,0)
Copy down as needed.
I like Sancho.s' answer. I would include an IFERROR in your solution, so that if there is no answer corresponding to your search, you will not get #N/A.
Assuming your SHORT TERM BORROWING table is in columns A and B, and the dates you are searching are in column D, then the formula in column E would be:
=IFERROR(VLOOKUP(D2,A:B,2,FALSE),"")
This assumes that you want a blank cell as opposed to 0 in a cell that returns no value. If you want something else in there, replace the "" with another value.
Related
[Goal]
I want to be able to count unique values that are present in 2 different sheets only if they exist in both sheets.
[Details]
First, there are 2 sample data sheets (Data A, Data B) within the same Spreadsheet and it also has a sample dashboard to do the calculations. One thing to note about the data sheets is that they have different ranges, so they have different number of columns and rows. However, a couple things they have in common are the Month and ID columns.
Next, in the Dashboard sheet, there are 3 cells where B3 is the Month selector, C3 is to count the number of unique IDs that are included in both sheets (Data A & Data B) based on the month. With D3, I would like to count the number of unique IDs that are included in both sheets (Data A & Data B) where the the Month are the same AND Data B sheet's Cumulative column is 1.
[What I tried so far]
I tried using the COUNTUNIQUEIFS function and had the range as an array (by using the curly bracket) in the below way, however, it didn't work.
=COUNTUNIQUEIFS('Data A'!$B:$B,'Data A'!$A:$A,B3,'Data B'!$A:$A,B3)
I also tried without making the range argument an array.
=COUNTUNIQUEIFS('Data A'!$B:$B,'Data B'!$A:$A,B3)
Both attempts results in 1 for February 2023 when it should return 2. The weird thing is that January 2023 should return 3 and it correctly returns 3.
Hope someone can help me out with this. If there's a more elegant solution to achieve this by using Google Apps Scripts, I'd like to see hear about that as well.
You can try filtering both ranges for month, and the FILTER again by comparing them with MATCH and counting the remaining results:
=LAMBDA(ar,br,COUNTA(IFERROR(FILTER(ar,NOT(ISERROR (MATCH(ar,br,0))))))
(FILTER('Data A'!B:B,'Data )A'!A:A=B3),FILTER('Data B'!B:B,'Data B'!A:A=B3))
And just add an additional filter for the next column and the cumulative =1 'Data B'!C:C=1
=LAMBDA(ar,br,COUNTA(IFERROR(FILTER(ar,NOT(ISERROR (MATCH(ar,br,0)))))) (FILTER('Data A'!B:B,'Data )A'!A:A=B3),FILTER('Data B'!B:B,'Data B'!A:A=B3,'Data B'!C:C=1))
I have a date in column A, for example: 1/2/2022. When 30 days have passed, I use the following formula to tell me something has expired:
=AND($A2<=(TODAY()-30),$A2<>"")
The result if expired: TRUE.
Sometimes, I have another value in column B. This value indicates when something has been closed and expiration should no longer apply.
How can I modify the above formula to take my column B date into consideration? so that if any value is detected in column B at all, my result will be custom text, like "N/A"?
You can use IF or IFS combined with ISDATE or ISBLANK:
=IFS(ISDATE(B2),"N/A",AND($A2<=(TODAY()-30),$A2<>""),"Yes",TRUE,"No")
(put "N/A" if B2 is a date, "Yes" if your original formula evaluates to TRUE, otherwise "No")
or
=IFS(AND(ISBLANK(B2),$A2<=(TODAY()-30),$A2<>""),"Yes",ISBLANK(B2),"No",TRUE,"N/A")
I have a problem writing down a formula or a script in Google Sheet or Google App Script to find and count the values in a sheet where the number and references to the columns change.
I have a script that copy&paste the Sheet files for the staff shifts of every week from a Drive folder and merge them side by side (in horizontal).
In this sheet that contains all the shifts merged I want to count all the cells of the staff filtered only for handler and picker (column B, K, etc.) according to a specific date (row 3) for every hour.
Example: if today is 28/10/2020 find the right column with the same date in row 3 --> column E, count all the values from row 4 filtered by picker or handler for every hour (10 people at 05 AM).
Do you think that I can implement this with a formula (like a matrix, vlookup, etc.) or should it be written as a Script?
Thank you very much,
Marco
Please use the following
=COUNTA(QUERY({A3:I;J3:R},"select Col"&MATCH(A1,A3:I3)&"
where Col2 matches 'Technician|Picker' "))
Where B1 holds the date you wish to search for (28/10/2010)
Try the below formula. Replace date with your search date.
=COUNTA(INDEX(A4:R14,,MATCH(DATE(2020,10,28),A3:R3)))
This was earlier tagged as excel. This is how to "tackle" this in excel (office 365):
In a clear column use the following formula to get the unique hour-values that are in the column that equal today:
=UNIQUE(FILTER(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)),INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0))<>""))
In the column next to that type the following to get the result of the count of those unique values for that day:
=COUNTIF(INDEX(($4:$1048576,,MATCH(TODAY(),$3:$3,0)), FILTER (I:I,I:I<>""))
Where I:I in FILTER (I:I,I:I<>"") needs to be changed into the column you put the first formula.
I'm trying to run a formula to identify in which row a total sum is reached.
I've been able to do that calculation when I have an entire range of cells to work with, however, I'm doing a filter / join calculation because I need to do this from an individual row with all the data instead of an entire range of cells.
Here is an example google sheet (EDITABLE - feel free) where you can see the range and working formula (both below). Help getting this from the single-cell versions on the top would be very helpful. The error I get with both row() & index() formulas is that the "argument must be a range".
If there's another way to do this besides the single-cell I had that doesn't require referencing the range (e.g. using FILTER) then I'm open to it.
My desired result is to be able to pull the get the second column (date) at the point when the sum is reached (can be via the INDEX & MATCH formula I used or an alternative). This will tell me the earliest date that feeds into the desired sum.
Yes unfortunately you can't do that trick with SUMIFS to get a running total unless the column being totalled is an actual range.
The only approach I know is to multiply successive values by a triangular array like this:
1 0 0 ...
1 1 0 ...
1 1 1 ...
so you get just the sum of the first value, the first 2 values, then 3 values up to n.
This is the formula in F5:
=ArrayFormula(match(E14,mmult(IF(ROW(A1:INDEX(A1:ALL1000,COUNT(split(A5,",")),COUNT(split(A5,","))))>=
COLUMN(A1:INDEX(A1:ALL1000,COUNT(split(A5,",")),COUNT(split(A5,",")))),1,0),TRANSPOSE(SPLIT(A5,",")))))
And the formula in F6 is just
=to_date(INDEX(TRANSPOSE(SPLIT(B5,",")),F5,1))
EDIT
You might have guessed that the above formula was adapted from Excel, where you try to avoid volatile functions like Offset and Indirect.
I have realised since posting this answer that it could be improved in two ways:
(1) By using Offset or Indirect, thus avoiding the need to define a range of arbitrary size like A1:ALL1000
(2) By implying a 2D array by comparing a row and column vector, rather than actually defining a 2D array. This would give you something like this in F5:
=ArrayFormula(match(E14,mmult(IF(ROW(indirect("A1:"&address(COUNT(split(A5,",")),1)))>=
COLUMN(indirect("A1:"&address(1,COUNT(split(A5,","))))),1,0),TRANSPOSE(SPLIT(A5,",")))))
which could be further simplified to:
=ArrayFormula(match(E14,mmult(IF(ROW(indirect("A1:A"&COUNT(split(A5,","))))>=
COLUMN(indirect("A1:"&address(1,COUNT(split(A5,","))))),1,0),TRANSPOSE(SPLIT(A5,",")))))
How can I add two different COUNTIF formulas that look at different criteria. For example:
Column A shows me dates 4/1/2013
Column B shows me the Type of product HQTT
I plug this formula in:
=COUNTIF(A:A,M3)+COUNTIF(B:B,"HQ TT")
However this gives me 2 when it should be 1 because I only have one row that says 4/1/2013 with the product HQTT.
Your formula is saying:
Count all the '4/1/2013' values in column A.
Count all the 'HQ TT' values in column B.
Give me the sum of these 2 counts.
I think what you want is a 3rd column, =A&B and a formula on that =COUNTIF(C:C,M3&"HQ TT")
For the sake of an answer, per OP:
I used this formula
=COUNTIFS(A:A,Q37,B:B,"HQ TT")
and Im getting the results I need.