Hi I have following table created for my trading journal.
As you can see from the formula,
I am matching a string Long or Short based on that I am calculating the values whether I made profit or loss.
Interestingly, in short position, The
value should be -4.88 i,e (204.9*48.7804878 - 205*48.7804878). But somehow I am not getting the negative symbol out. How to rectify this?
Simply use
=ifs(F3="Short",________,F3="Long",_________)
or
=ifs(REGEXMATCH(F3,"Short"),______,REGEXMATCH(F3,"Long"),________)
Related
I have my data organised in a NxN table with coupled columns {quantity,code} (see image below).
I'm looking for a function able to calculate total quantity by code.
I've tried with SUMIF, but it seems to work only with a fixed sum range, whilst I need a RELATIVE sum range.
Can you address me to the right solution?
i think this should work:
=ARRAYFORMULA(SUM(A2:G4*(B2:H4=A7)*(A1:G1="quantity")))
just using multiplication of booleans to get at the correct values is sometimes simpler.
I'm trying create a list of sequential dates from a set date to the most recent date in another column.
=ARRAYFORMULA(IF(OR(A2:A=MAX(C:C),A2:A=""),"",DATEVALUE(A2:A+1)))
I use MAX() to find the dates most recent date in column C. What I'm trying to get this formula to do is to recursively check the date in the cell above to determine if the max date has been reached. I've made sure A2 already has the set starting date.
The output is in only one cell though and I don't know why.
Thank you for the help.
What appears to be troubling your current array formula is that as defined it goes on forever and is self-referential. There may be a way to make it by setting preferences to be iterative and helping it interpret getting to repeated cells with "" as convergence.
Here is a way to sidestep those issues. You can bulletproof it more (for example, by encasing it in an IFERROR), but basically you can calculate exactly how many entries you need, and then set your range in the Array formula accordingly. In A3 you place the following:
=arrayformula(DATEVALUE(Row(indirect("A3:A"&(max(C:C)-A2+2)))+A2-2))
which will construct the exact range you want, then calculate each entry with an explicit rather than recursive formula.
EDIT: the above implementation assumes you need at least 2 dates. You can handle that case and other weird ones with the following, less readable formula, =if(max(C:C)>A2,iferror(arrayformula(DATEVALUE(Row(indirect("A3:A"&(max(C:C)-$A$2+2)))+$A$2-2))),"")
I have a Google Sheet containing a column with values, Price/sqft, which I would like to average, but only including values for which an adjacent column, Outlier? does not contain the word yes.
I took a stab at it following the AVERAGEIF documentation, but I'm getting a 'divide-by-zero' error:
Another way to do it would be to create a separate column which contains the conditional value and compute a regular AVERAGE on that. Is this the way to go? Or is there a way to do this in one go using AVERAGEIF?
You should use the formula =AVERAGEIFS(Q5:Q13,S5:S13,"<>yes")
Here, the syntax is like AVERAGEIFS(average_range, criteria_range1, criterion1)
I hope this will be helpful.
If you do use Averageif, you need to put the criterion range first and the average range last
=averageif(B2:B10,"<>Yes",A2:A10)
I am attempting to make a Google Sheet that has a column for a rate and a value of that rate. Each night I am adding a new value to the bottom of this list so I want it to continue as an infinite list. What this sheet should do is look down the list of rates, if the rate matches a predefined rate, it should add the corresponding value to the total for that rate. I have four common rates that occur in no particular order and with some given value. I would like to total the values for each of those rates and give them in the totals section so each rate can be easily referenced.
Is there a way to do this using Google Sheets built-in commands? Pseudocode would be something like IF(A2:A = rate, add value in B to total). I know to make an infinite reading of a column by A2:A, but I don't know how to check each value as it goes through that column. I have attached a test spreadsheet with some sample values and the output that should be given by the formula. Thank you in advance for your help.
https://docs.google.com/spreadsheets/d/19k1DMipSsI9tWSjTXrVAPzPoaenWS6WYmlwe201_WQk/edit?usp=sharing
I managed to discover my own answer using the SUMIF statement. My code for the rate of .75 is ""=SUMIF(A2:A,"=.75",B2:B)"". I ran into some more trouble with the section for a different rate because I was having trouble saying not equal to .75 or 1 or 1.5 or 1.75. I solved this problem by completely bypassing it and adding the all the values and subtracting away the values already added. I would still like to know how to give the list of "ors" if someone could shed some light on this. But I now have a working solution regardless. I have updated the test sheet to show the solution.
Ive been working on a spreadsheet to examine something. I was converting a recursive formula into a linear one. The initial value or first state was 60. To get to the second state you 240. This is done by taking the previous state, doubling it, and adding 120. Which leads to the 3rd and 4th states of 600 and 1320. Now this base formula was clear enough that the (60+120)*2^(n-1)-120 accurately expresses it.
My second part comes from needing to add in the ability to decrease the costs while still staying true to the state. So the last formula only works when the cost reduction is 0. After considerable effort (I kept having minor rounding errors) I arrived at (ROUND(60-60*0.015*B$2)+(120-round(120*rounddown(B$2/3)*0.03,0)))*2^($A2-1)-(120-round(120*rounddown(B$2/3)*0.03,0)).
To test the formulas I created a table with the following values, with a2=1 to a5=4, and b2=0 to h2=6. Now I was using google spreadsheets to examine the information. When I populate the table I found that all the values were correct with the formula, except on G. On G the values are identical to F.
So to try and correct this I have deleted the information from the cells, deleted the columns, and even tried again in a new spreadsheet. But in all cases G=F when it should not. I cant figure out why I'm getting a duplicate column.
The information on row 3 is the values that it should be using.
The expected values are G4=55, G5=226, G6=568, G7=1252.
In case anyone wanted to know, I finally managed to solve the issue. I needed to round in one more place. The following is the formula that has worked for my current testing.
sum((ROUND(60-round(60*0.015*A$2))+(120-round(120*rounddown(A$2/3)*0.03,0)))*2^($A25-1)-(120-round(120*rounddown(A$2/3)*0.03,0)))