I need to calculate a column in google spreadsheet.
Column B is a price column (priceUSD). I want to be able to calculate if the price the following day is 5 % higher or more, then it should return a 1.
Otherwise a 0 (if price is less than 5% higher the following day)
I do not want to add more columns for this only using column D
(column A is a date column)
A B C D
date priceUSD Addres Over5
=if(B1*1,05>B2) then return 1
Maybe, in D3, something like:
=ArrayFormula(1*(B2:B900*1,05<B3:B900))
Related
my title is potentially not that enticing. But I am trying to create a semi-dynamic formula in order to find a "stock on hand" up to a particular date in time. There is a set number of locations ids 1-10, and two product types 3 & 4.
It is not guaranteed that each location will have a stock count at the date in question. I want to use query to find THE MOST RECENT stock count where location and product type and <= date
here is the basic formula
=QUERY(Sheet1!A160:E3530,"SELECT D WHERE ((B = "&$H$1&")) AND (E <= date '"&TEXT(MAX($M$3),"yyyy-mm-dd")&"') AND ((A = "&G2&"))", true)
But I need to figure out how to use MAX to find the most recent date within the date range specified.
Any help appreciated!
EDIT 23/06/2021
You will note this is a fraction of the data I have in my set (in the example sheet), so most numbers show as zero, but the formula
=MAXIFS($C$3:$C$6040,$A$3:$A$6040,I3,$B$3:$B$6040,$J$2,$E$3:$E$6040,(MAX(QUERY($A$3:$E$6040,"SELECT E WHERE (E <= date '"&TEXT($R$2,"yyyy-mm-dd")&"') AND ((A = "&I3&")) AND ((B = "&$J$2&"))", true))))
works on my full data. So this finds the most recent record of equipment type 3 or 4, up to the specified date and from a specified yard. Further filtering is done based on a change type of "converted, removed,dead,added,etc". What I want to do now is do a monthly or fortnightly line chart over time, eg the 14th and 29th of each month, or the 20th of each month and plot the the sum of each column J:Q. To start I hoped to use the date in U:U and populate the V:AC accordingly.
I have played with the onEvent script but I am struggling to make progess here
I need to sum the daily sales of each product ASIN. Sounds easy but I can`t do it.
On the left, you can see the data. At the right, the empty table that I need to create.
use:
=QUERY(K2:M; "select K,sum(M) where M is not null group by K pivot L")
Use an IF statement on the columns that you want summed.
For your example, it would be something like this:
in Cell P2
=IF($L2 = P$1, $M2, 0)
This translates to
If ((the text in column L row 2 = the text in p1), take the units from column m row 2, else take 0)
The $ are there to indicate you always want that column/row. So we always want to evaluate column L at the start and Row 1 in the comparison.
Then at the last row of the sheet you have a SUM function for the column
=SUM(P2:P100)
or whatever the end is
Working example here: https://docs.google.com/spreadsheets/d/1zhQMV6o1tF2P_kWbXDPdnVKzYnd-Dsvg2h7YiHWSaNI/edit?usp=sharing
I have a sheet with a timeline that shows a month per row in column A and an amount in USD next to that month in column B.
I want to be able to specify amounts in column G with a start and end date for that amount in columns E and F.
What I am trying to achieve is that the values in column B are automatically calculated by looking at the start and end dates specified in columns E and F and then taking the corresponding value from column G if the date in column A falls in between the date range specified in E and F.
I have found many suggestions for similar problems online but wasn't able to get any of them to work for my specific case. Any help is very welcome
You could do it as an array formula like this:
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("`E3:E"&count(E3:E)+2)),"YYMM"))*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))*transpose(indirect("G3:G"&count(G3:G)+2)),(INDIRECT("G3:G"&count(G3:G)+2)+2)^0))
The idea is to develop a 2D array where the rows are the months and the columns are the amounts for matching time periods. Then use the standard Mmult method to get the row totals of the array.
Using indirect for the ranges makes the formula longer but using full-column references would be slow as it would result in a nearly 1000 X 1000 array for a default-sized sheet.
EDIT 1
Or shorter
=ArrayFormula(mmult((text(indirect("A2:A"&count(A2:A)+1),"YYMM")>=text(TRANSPOSE(indirect("E3:E"&count(E3:E)+2)),"YYMM"))
*(text(indirect("A2:A"&count(A2:A)+1),"YYMM")<=text(transpose(indirect("F3:F"&count(F3:F)+2)),"YYMM"))
,INDIRECT("G3:G"&count(G3:G)+2)))
because you can combine the row totals step with multiplication by column G.
EDIT 2
Alternatively you could just employ a much simpler pull-down formula using SUMIFS:
=ArrayFormula(sumifs(G$3:G,eomonth(E$3:E,-1)+1,"<="&A2,F$3:F,">="&A2))
This uses Eomonth to change all the start dates to the first of the month so they can be compared to the dates in column A correctly. The formula still has to be entered as an array formula because of the Eomonth calculation.
Note
The equivalent pull-down formula to the original array formulas above would be
=ArrayFormula(sumifs(G$3:G,text(E$3:E,"YYMM"),"<="&text(A2,"YYMM"),text(F$3:F,"YYMM"),">="&text(A2,"YYMM")))
but this gives zero for all rows - the reason for this is not obvious to me at time of writing.
I have a large set of data that's updated every 2 weeks, so I'm looking to simplify the solution.
Imported sheet has data from D6:G. The date is in Column B.
Right now, I insert column H and use
=ARRAYFORMULA(if(isblank(B6:B),"",datevalue(B6:B)))
In a new sheet, I import the data and order by Col H (the converted date) and Col G (the employee's name).
=query(TimeApr10!B6:H,"select B,C,D,E,F,G where H is not null order by H,G asc")
Is there a way to combine the two steps by converting Col B in the query to datevalue? If I don't convert the date, the ordering doesn't work.
Example
Column B is my monthly sales goal.
Columns E,F,G,H, etc are the number of sales in a given day.
When I meet my monthly goal, Column C will display 100%.
In Column D I would like to display the date asscoiated to the column of the last sale when our monthly sales goal is met.
The equation I have right now for Cell D is:
=IF(C2=100,D=
Try:
=IF(C1=100,"Day Goal Was Met","")