I have an issue with excel, lets say someone purchased something in (A1)100 dollars and i have to cut (B1)4.5 % of the said amount as tax. then when i want to insert the remaining amount after the deduction of tax(C1) that is (A1)-(B1). it shows 96 dollars. but actually it should be 95 dollars.
Check the format of the cell that has the result (C1). Make sure it is number and has two decimal places.
Related
I'm trying to calculate the cumulative total in a column. It needs to sum or subtract if the value of (A) cell is set to buy or sell. here is an example:
A (task)
B (qtty)
C (total)
calculation explanation
buy
10
10
sum 10
buy
10
20
sum 10
sell
5
15
subtract 5
buy
20
35
sum 20
sell
10
25
subtract 10
I´m using the folowing formula:
={"Total", ARRAYFORMULA(IF(LEN(A2:A),IF(A2:A="buy",SUMIF(ROW(B2:B),"<="&ROW(B2:B),B2:B), "NEED CODE FOR SELL" ),))}
Is there another way to do the calc?
I don't want to use negative values to subtract, because the values are used in other formulas.
Thanks in advance.
try this:
=SCAN(0,A2:A,LAMBDA(ac,cv,if(cv="",,ac + ifs(cv="buy",OFFSET(cv,,1),cv="sell",-OFFSET(cv,,1)))))
You can use SCAN:
=ArrayFormula(IFNA(SCAN(,A2:A&B2:B,LAMBDA(tot,cur,tot+REGEXEXTRACT(cur,"\d+")*IF(REGEXMATCH(cur,"(?i)buy"),1,-1)))))
Or:
=SCAN(,B2:B,LAMBDA(tot,cur,IF(cur,tot+IF(INDEX(A2:A,ROW(cur)-1)="buy",cur,-cur),)))
It's also possible to do it with Sumif:
=ArrayFormula(if(A2:A="",,
sumif(row(A2:A)*if(A2:A="buy",1,9^9),"<="&row(A2:A),B2:B)-
sumif(row(A2:A)*if(A2:A="sell",1,9^9),"<="&row(A2:A),B2:B)))
Of course, there's no particular reason for doing it this way now that you have lambdas. I'm including it for old time's sake as I was one of the first people to use Sumif in this way.
I am trying to record the time it takes for a number of things to occur, and can't seem to get Google Sheets to understand my input. I want to be able to type something like "26:30" into a cell, and have the spreadsheet understand that this means 26 minutes and 30 seconds, and then be able to use that number in formulas, e.g. to return the shortest of a series of times, or the difference between two times.
Also, the vast majority of the numbers I type in will be under an hour, so I don't want to have to type in something like "0:26:30" every time, just for it to understand that I mean 26 minutes, not 26 hours. However for the rare occasions where something is longer than an hour, I want to be able to be able to type something like "1:10:23" and not "70:23".
If possible, I would rather achieve this through directly formatting the cell I type the time into, rather than enter it in one format and have it converted in a separate cell via a formula.
Is there a way to do this that meets all of these goals?
google sheets is not designed in such a way. if you want to type in 26:30 then the best course of action is as follows:
convert cells to Plain Text, type in your duration, and account for your rules within formulae. to convert a text string into a value for the sake of calculation you can use the following principle
=ARRAYFORMULA(IFERROR(IF(REGEXMATCH(A1:A, ":\d+:"), A1:A*1, ("0:"&A1:A)*1)))
few examples:
=ARRAYFORMULA(TEXT(AVERAGE(IF(REGEXMATCH(A1:A2, ":\d+:"),
A1:A2*1, ("0:"&A1:A2)*1)), "[m]:ss"))
=ARRAYFORMULA(TEXT(SUM(IF(REGEXMATCH(A1:A2, ":\d+:"),
A1:A2*1, ("0:"&A1:A2)*1)), "[h]:mm:ss"))
=ARRAYFORMULA(TEXT(IF(REGEXMATCH(A2, ":\d+:"), A2*1, ("0:"&A2)*1)-
IF(REGEXMATCH(A1, ":\d+:"), A1*1, ("0:"&A1)*1), "[m]:ss"))
At this point in time there doesn't seem to be a way to directly format a cell such that Google Sheets recognises it as MM:SS instead of HH:MM, so I've had to go with formulas instead. Sharing the solution I used below.
I set it up so that the user entered the time into cell A1 in the form MM:SS or H:MM:SS and I formatted this cell as plain text, then had a second cell formatted as 'time duration' where it converted the input of A1 using the following formula:
=time(left(A1,if(len(A1)<6,"",len(A1)-6)),right(left(A1,len(A1)-3),2),right(A1,2))
To break this down:
It starts by assuming the contents of A1 is a text string with 5 or more characters in the form MM:SS or H:MM:SS or HH:MM:SS. It does not include any sort of error handling to check this is true.
The time(X,Y,Z) part of the formula converts different inputs into hours, minutes and seconds, respectively, and produces a number in the format HH:MM:SS, which is recognised as a time, and can therefore be used in formulas. Note that the cell has to be formatted as 'time duration' to display correctly.
In the above, Z is right(A1,2) which extracts the last two characters of A1, i.e. the SS part of the input. These end up as seconds.
Likewise, Y is right(left(A1,len(A1)-3),2) which extracts the 4th and 5th characters from the right of the text string of A1, i.e. the MM part of the input, after the :. This number is then recognised as minutes.
Finally, X is left(A1,if(len(A1)<6,"",len(A1)-6)), which basically says "if A1 is less than 6 characters then it must not have hours, so leave blank, otherwise extract out all characters except the last 6", i.e. the HH part of the input, if it exists. This number (which may or may not be 0) is then recognised as hours.
I'm sorry to ask this, I have not any code skills and I've trying to figure that out for a few hours now.. I think an image will be better for you to understand what I want:
I want A2 to show the sum of the products in G:G that fit certain conditions (2020,jan,buy). I haved tried several formulas but I came up with this one as the closest, I think, but still won't work:
=arrayformula(SUMIFS(E:E=B1,F:F="jan",G:G="buy",H:H))
Can anyone explain me how to achieve that?
Thanks very much :)
Please use this formula in A2 it will work
=sumifs(G2:G100,D2:D100,2020,E2:E100,"jan",F2:F100,"buy")
So basically, sumifs formula is right one as you want to check for multiple conditions.
so this is how this formula work
=sumifs(sum_range,criteria_range1,criteria1,criteria_range2,criteria2,...)
In your case your same range is column 'G' so if you have a finite range like only 25 rows you have in your table then instead of G2:G100 you can use G2:G25 as G1 is containing label and make sure that all other ranges also similar to the range of column G. for example if you take range of G2:G100 means 99 rows then you should take E2:E100 or E3:E101(range of 99 rows, that rows must be 99 and series start and end number is as per your requirement, similar case for other columns in this formula)
you have to check 2020 in column D, so you criteria_range1 is of D column I took it D2:D100 and criteria 1 is 2020 as it's a number it doesn't need double quotes
criteria 2 is you need to check Jan in column E so criteria_range2 is column E I took it E2:E100 and criteria 2 is "jan" as it's not a number so I took it in double quotes.
criteria 3 is you need to check 'buy' in column F so Criteria_range3 is column F. I took it as F2:F100 and criteria 3 is "buy" again it's not a number so took it under double quotes.
I'm creating a spreadsheet for keeping track of my stock trades. This column will be called "Risk" and it will show how much money I want to risk per share on trade and at what price I will have to close the trade at if prices go against my position. So, for example, if I bought shares of Ford at $20 and was willing to risk losing 30 cents per share before closing the trade, I want to be able to type "30 19.70" in a cell and have the custom number format change it to "30c - $19.70". How do I implement this?
I have tried using the following custom number format on Google Spreadsheets but it doesn't work:
0 "c - " $0.00
I input the following into a cell: 30 19.70
I want this result to be: 30c - $19.70
But I'm getting this output: 30 19.70
unfortunately, this is not possible for several reasons:
your entry: 30 19.70 is not a number. it's a text string. that's why 0 "c - " $0.00 will never work because those zeros are trying to find numbers to catch up on them, but your entry is not a number.
text can't be divided in between with "c - ". you can have #"c - " or "c - "#, but #"c - "#.# will output: 30 19.70c - $30 19.70.30 19.70
best you can do is to enter 30 in one cell and 19.70 in another cell and use a formula in a 3rd cell:
=A145&"c - $"&TEXT(B145, "##.#0")
or: =JOIN("c - $",INDEX(SPLIT(A150," "),1,1),TEXT(INDEX(SPLIT(A150," "),1,2),"##.#0"))
I have a View() with a link to make a payment. Link looks something like this
Pay Now
My problem is Model.Amount has the amount format like this 20.00 or 100.00 because the DataType is money and its adding extra zero's.
I need to remove the '.' so it reads 2000 or 10000.
How can I achieve that?