Sorry if this is a very basic question - but I'm struggling how to find this on a google search.
Essentially what I need is a way to keep subtracting from a number if an condition is met.
I can do the IF statement fine for one cell, but am unsure how to keep deducting from the value.
=IF(D9= "Y", 100-E9)
The screenshot below explains it better. Essentially if there is a 'Y' then the figure on the right should subtract from 100. If 'N' then nothing should happen.
Thanks for any help given in advance.
enter image description here
Sure you can. Sounds like you want to use SUMIF combined with a subtraction.
For your case, the formula will likely be:
=<start value>-SUMIF(<range of Y/N>, <condition>, <range of values>)
e.g. for a sheet with:
either Y or N in column A, from A1 to A10
numeric values in column B, from B1 to B10
where the value in B1 is to be subtracted if A1 is Y
the start value is 100
You would use =100-SUMIF(A1:A10, "=Y", B1:B10)
Related
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'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,",")))))
Updated: While the solution provided =IF(A2>A1,IF(A2>MAX(A$1:A1),ROW()-1,IFERROR(B1+1,1)),1) does work for the original test data, it doesn't work for a more complex data set, see the second screen shot below:
Original question:
I have a need to process a column (A in the example) of numbers that represents a value changing over time, and establish for how many rows the present row's number has been the largest number, and report that as illustrated in Column B.
What I can't figure out is whether there is a way of producing column B using spreadsheet functions or if I need to write some apps script to do the calculations. I've looked at the usual suspects like MAX() and LARGE() but they don't quite do what I want.
What I want is something like MAXSINCE(A99, A:A98) but that doesn't exist.
Updated data set which still doesn't have an answer for the question: for how many rows has this row had the largest value?
Logic Flow:
Check if current value A2 is greater than previous value A1; If not, return 1
If the above is true, Check whether current value is greater than the present MAX. If so, return current ROW's number - starting offset 1 else add 1 to previous value B1
Code Sample:
B2:
=IF(A2>A1,IF(A2>MAX(A$1:A1),ROW()-1,IFERROR(B1+1,1)),1)
Drag fill down
I have a tournament spreadsheet that has a list of names in column "D" (between 20 and 150 entries) and the table number that each person is assigned to (column "E").
In column "I", I have a ridiculous formula that creates a list of the number of seats available at each table (this information changes from one event to another).
Column "G" is my problem. I want to run through the contents of column "E" and anytime there is a value in column "E" that matches the contents of column "I", to give the the contents of column "D".
Here is my formula as it currently stands in cell G3:
{=IFERROR(INDEX(D$3:D$150,SMALL(IF(E$3:E$150=I3,ROW(E$3:E$150)-ROW(E$3)+1),ROWS(E$3:E3))),"")}
The formula works perfectly for all values in column "E" as long as the value in column "E" is 1. This formula works beautifully in Google Sheets but Excel seems to process the ranges differently. I've tried with both a standard formula and an array formula without success.
Any advice would be greatly appreciated.
One additional note, I can use VBA if needed but I would prefer to stick with functions.
for this example I used the following formula:
=INDEX($C$14:$C$25,AGGREGATE(15,6,(ROW($D$14:$D$25)-ROW($D$14)+1)/($D$14:$D$25=H16),COUNTIF($H$16:H16,H16)),1)
You will need to adjust the ranges to suit your needs.
From my testing, the problem appears to be with the ROWS(E$3:E3) as the second argument for the SMALL function. Basically, when you get down to your first 2 in row 12, you are asking the small function for the 10th smallest value in D that has 2 in column E. Since it looks like you are only expecting eight players, this will never find anything.
Try changing ROWS(E$3:E3) to COUNTIF(I$3:I3, I3).
That will count how many 1's or 2's you've already passed in column I, so when you get to the 2's, it should reset and ask for the first smallest.
#Forward Ed. Thanks for your input. That helped get me on the path that I needed.
Here is the formula that ended up working for me:
{=IFERROR(INDEX(D$3:D$150,SMALL(IF(E$3:E$150=I3,ROW(E$3:E$150)-MIN(ROW(E$3:E$150))+1),J3)),"")}
Could you please help I need a COUNTIF formula.
The range is Cell A1 to Cell N1, the criteria is if there is a text with A the value of A should be 1 in the answer, and if the text is H the value should be 0.5?
Please try:
=COUNTIF(A1:N1,"A")+COUNTIF(A1:N1,"H")*0.5
though you might be better off entering 1 instead of A and .5 instead of H and just using =SUM.
This is not case sensitive (A or a should work equally).