In the google sheets, I have a bunch of negative and positive amounts in the same vertical rows. Now in a particular cell, I want to show all the sum of positive values and in another cell, I want to show the sum of all negative values. I want to calculate the total debit and credit amount actually.
Here are some sample data I wanna calculate
Sample data
Any help will ve appreciated ^_^
for negative values
=sumif(range, "<0")
for positive values
=sumif(range, ">0")
For data in column A from A1 to A100, try:
sumproduct((A1:A100)*(A1:A100>0))
and for the negatives:
sumproduct((A1:A100)*(A1:A100<0))
(the second formula will yield a negative value)(will also work for Excel)
Related
https://docs.google.com/spreadsheets/d/1Z99BFJws_fjrY6Z143opVntSqI5t8vG8Dkyk5-zWx68/edit?usp=sharing
A2:A16 is a column of the values
C2:C16 adds up consecutive positive and negative values in the column but I would like a formula that could get the average of those consecutive values into one cell.
H7 shows what should be the answer for the average of those 3 consecutive positive numbers.
H13 shows what should be the answer for the average of those 4 consecutive negative numbers.
Is there a formula that can do this?
This formula will use helper column in B2:B16
In B2 type this formula:
=IF(SIGN(A2)=SIGN(A1),B1,0)+SIGN(A2:A16)
and drag down up to B16
This will help us determine the largest count of positive and negative number.
It should look like this:
In H7 insert this formula:
=ARRAYFORMULA(AVERAGE(OFFSET(C2,MATCH(E4,B2:B16,0)-E4,0,E4,1)))
This will give us the average of max consecutive positive numbers.
In H13 insert this formula:
=ARRAYFORMULA(AVERAGE(OFFSET(C2,MATCH(-(E5),B2:B16,0)-E5,0,E5,1)))
This will give us the average of max consecutive negative numbers.
Output:
Note: You can place the helper in any column with same row and hide it, just change the formula of H7 and H13 that are referencing to the helper column. Also if the set max consecutive number appear more than 1, it will only calculate the first occurrence.
References:
SIGN
ARRAYFORMULA
AVERAGE
OFFSET
One column has numbers (always with 2 decimals, some are computed but all multiplications and divisions rounded to 2 decimals), the other is cumulative. The cumulative column has formula =<above cell>+<left cell>.
In the cumulative column the result is 58.78, the next number in the first column is -58.78. Because of different formatting for zero than for positive or negative numbers, I spotted something was wrong. Changing the format to several decimals, the numbers appear as:
£58.780000000000000000000000000000
-£58.780000000000000000000000000000 £0.000000000000007105427357601000
The non-zero zero is about 2^(-47). Another time the numbers in the same situation are:
£50.520000000000000000000000000000
-£50.520000000000000000000000000000 -£0.000000000000007105427357601000
How can that happen?
Also, if I change the cell in cumulative column into the actual number 58.78, the result suddenly becomes zero.
Google Sheets uses double precision floating point arithmetics, which creates such artifacts. The relative precision of this format is 2^(-53), so for a number of size around 2^6 = 64 we expect 2^(-47) truncation error.
Some spreadsheet users would be worried if they found out that "58.78" is actually not 58.78, because this number does not admit an exact representation in this floating point format. So the spreadsheet is hiding the truth, rounding the number for display and printing fake zeros when asked for more digits. Those zeros after 58.78 are fake.
The truth comes to light when you subtract two numbers that appear to be identical but are not — because they were computed in different ways, e.g. one obtained as a sum while the other by direct input. Rounding the result of subtraction to zero would be too much of a lie: this is no longer a matter of a small relative error, the difference between 2^(-47) and 0 may be an important one. Hence the unexpected reveal of the mechanics behind the scenes.
See also: Why does Google Spreadsheets says Zero is not equals Zero?
Hi Everyone my name is Ray
col A col B col c col d (what i want to display)
Emoji | Sentiment | message | sentiment_message (goes in seperate sheets)
😀 POSITIVE 😃 POSITIVE
😁 POSITIVE 😃 POSITIVE
😂 POSITIVE 😃 POSITIVE
😃 POSITIVE 😂 POSITIVE
😒 NEGATIVE 😂 POSITIVE
😓 NEGATIVE 😓 NEGATIVE
😅 POSITIVE 😓 NEGATIVE
I want to check if the emoji in col c is present in col a, I can do that with this code
=if(match(c2, a:a, 1), b:b, 1)
The problem is the b:b, i want the respective sentiment from each match.
You can do this with VLOOKUP instead of match, as it will return the sentiment instead of the value if you want.
=VLOOKUP(C2,A:B,2,false)
I'm trying to find a Google Sheets formula that will calculate the total amount of a target number if I have a known number which is a known percentage of that number; say I know that 300 is 20% of x. How do I calculate for x?
I know this is not too difficult to calculate mathematically, but how would I write it in a cell formula?
If 300 is 20% or ²⁰⁄₁₀₀ or ¹⁄₅ of x then multiply 300 by ¹⁰⁰⁄₂₀ or ⁵⁄₁ or 5 to get x.
With 300 in A1 and 20% in B1,
=A1*(1/B1)
I have a table that has frame numbers in one column and corresponding color moments in the other column. I found them using openCV.
Some of the frames have extremely high values and rest very low. How can I extract the frames with very high peaks ?
This is the plot of the distribution, I tried to use Gaussian smoothing and then thresholding on the plot below.
I got this result.
Now how should I proceed ?
Basically you are looking for a peakfinder...MATLAB has a peakfinder function to find peaks...
I did not find any ready made API in OpenCV for this so I implemented the peakfinder of MATLAB...the algorithm goes this way...
Initial assumptions or prior knowledge can be a) you can have 'n' peaks in your distribution b) your peaks are separated by a minimum window 'w' i.e no two peak are closer than 'w'.
I can tel you the window implementation. Start at a data point . Mark its position as current index and check in its left and right neighbourhood of length 'w' whether a value more than the value at current index exists or not.
If yes move to the point. Make the point the current index and repeat 2.
If no then its your local maxima. Move ur current index by 'w' length and repeat 2 till you reach data set end.
try to implement this and check MATLAB help for peakfinder. If no luck I can post the code..
EDIT after seeing your edited graph it seems the graph has well defined maximum peaks and hence what you can do is track the sign of the dy/dx of the graph. Maximum peaks are points where sign of dy/dx changes from positive to negative...in code language
vector<double> array_of_max_peak;
if (sign( x(n+1) - x(n) ) ) > 0
array_of_max_peak.push(x(n));