Sum values from month - google-sheets

I have a table of values, dates and categories:
5 1.09.2013 red
-7 2.09.2013 red
9 21.09.2013 red
-2 3.10.2013 red
11 28.09.2013 green
3 2.10.2013 green
8 16.10.2013 green
I calculate sum of values where category is green with:
=sum(filter(A:A;C:C="green"))
How to sum just values from October where category is green ?

The following formula can help:
=SUM(FILTER(A:A, C:C = "green", VALUE(REGEXREPLACE(B:B, "^\d+\.|\.\d+$", "")) >= 10))
UPDATE
Here a sample with the test data set.

Related

Fill missing dates in Google Sheets

I have two columns:
Col A Col B
01.02.2020 17
03.11.2020 24
03.11.2020 12
As I stated in another question, I tried to sum Col B, based on the month in Col A. The solution was the following formula (without the sort):
=ARRAYFORMULA(
SUMIF(
MID(A:A, 4, 2),
SORT(UNIQUE(MID(FILTER(A3:A, A3:A <> ""), 4, 2))),
B:B
)
)
Something I missed was the population of missing months. Therefore my question is: How can I populate the result table with the missing months and zeroes until values are entered? The desired output for the table above would be:e
Col A Col B Col C
01.02.2020 17 0
03.11.2020 24 17
14.12.2020 100 0
03.11.2020 12 0
0
0
0
0
0
0
36
100
If just doing it for the current year, this should be enough
=ArrayFormula(sumif(mid(A2:A,4,2),sequence(12),B2:B))
alternative:
=ARRAYFORMULA(IFNA(VLOOKUP(ROW(A1:A12), QUERY(A:B,
"select month(A),sum(B) group by month(A)"), 2, 0), 0))

Sum up numbers and text numbers per row in a range

I have the following sheet.
H I J K ... BD
2,3 4 2,4,7 ... 1
3,7 10 ... 8,13
The cell ‘H’ has 2,3 as text but cell ’I’ has the number 4, cell ‘J’ has the 2,4,7 as text and cell ‘BD’ has 1 as a number. All the cells that have 2 or more numbers as text are separated by commas
I want to sum all numbers and non-numbers to one single row using array-formula.
The result must be
BE
16
41
The range is between H2:BD with H1:BD1 for the headers
I have used this code:
=arrayformula(if(row(A1:A)=1;"BottleQty";if(len(A1:A)>0;
SUBSTITUTE(transpose(query(transpose(H1:BD);;COLUMNS(H2:BD)));",";"");iferror(1/0))))
but the result is
BE
2 3 4 2 4 7 1
3 7 10 8 13
Any help ??
Thanks in advance
=ARRAYFORMULA(IF(LEN(TRIM(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,99^99)))),
MMULT(IFERROR(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,99^99)), ", ")*1, 0), ROW(INDIRECT("A1:A"&
COLUMNS(IFERROR(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(A2:D),,99^99)), ", ")*1, 0))))^0), ))

Google sheets double query with selecting cell value as an explicit where condition

I have the following dataset:
Start day End Day Product ID Sells Unites
01/11/2018 08/11/2018 Blue DA_1000 $55,555.00 12
01/11/2018 08/11/2018 Red DA_1000 $1,321,321.00 55555
01/11/2018 08/11/2018 Blue DA_1000 $444.00 11111
01/11/2018 08/11/2018 Green DA_1000 $1,313,121.00 24
01/11/2018 08/11/2018 Aspire DA_1001 $11.00 55555
09/11/2018 16/11/2018 Black DA_1001 $786.13 49
09/11/2018 16/11/2018 Apple DA_1001 $629.55 22
09/11/2018 16/11/2018 White DA_1001 $0.39 1
17/11/2018 24/11/2018 Orange DA_1002 $0.00 515413
17/11/2018 24/11/2018 Blue DA_1002 $569.35 42
17/11/2018 24/11/2018 Red DA_1003 $315,154.00 40
25/11/2018 30/11/2018 White DA_1003 $45,464,564.00 36
25/11/2018 30/11/2018 Black DA_1003 $490.41 42
25/11/2018 30/11/2018 Vol DA_1004 $435.61 55
And I want to query from the products that have sells equal to=444, from this query I want to query again all of those that they're ID is equal to "DA_1000". and I managed to do that. But when I trying inserting to the where condition the explicit cell value I can't get any result,
This is the working query:
=query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='DA_1000',1)
This is the non-working query:
=query({query(A1:F15,"Select * Where E=444",1)},Select * Where Col4='TEST!N6',1)
This is the url for the google sheet.
Please assist.
If you would want the select-clause in a cell (ex: H10) you'd have to write in this cell:
="Select * Where Col4='"&TEST!N6&"'"
Then in your query:
=query({query(A1:F15,"Select * Where E=444",1)},H10,1)
Note that this can also be done in one query by writing in the reference cell
=" and D='"&TEST!N6&"'"
and then your query would look like this:
=query(A1:F15,"Select * Where E=444"&H10,1)
Maybe:
=query(A:F,"where E=444 and D contains 'DA_1000'")
would serve.

TikZ: plotting data file with missing values

I have this data:
data2 is missing the third point. So I thought, I'd define two different x columns and assign data2 to x2.
Problem: the third point of data1 goes up to 3 in the compiled graphic. If I have different and more values, points start to go anywhere, but not where they belong.
That is the code I've used:
\addplot[only marks, mark = diamond, color = orange, mark size = 3pt]
table[x=x1, y=data1]{example.dat};
\addlegendentry{data1};
\addplot[only marks, mark = square, color = gray, mark size = 3pt]
table[x=x2, y=data2]{example.dat};
\addlegendentry{data2};
\addplot[only marks, mark = o, color = blue, mark size = 3pt]
table[x=x1, y=data3]{example.dat};
\addlegendentry{data3};
And this is the graph I get:
Thanks a lot!
Btw. in the real data one data set is missing a x/y value in the middle of the data. I hope that doesn't matter compared to my example.
pgfplots is interpreting 2 tabs as a single separator. Thus, it sees the data file as:
x1 x2 data1 data2 data3
0 0 1 2 3
1 1 1 2 3
2 1 3
Solution 1. You can replace empty cells with NaN. pgfplots will interpret this correctly:
x1 x2 data1 data2 data3
0 0 1 2 3
1 1 1 2 3
2 nan 1 nan 3
Solution 2. Use another type of separator (e.g., semicolons or commas):
\begin{filecontents*}{example.csv}
x1;x2;data1;data2;data3
0;0;1;2;3
1;1;1;2;3
2;;1;;3
\end{filecontents*}
\pgfplotstableread[col sep = semicolon]{example.csv}\mydata
\begin{document}
...
Here I've included the data file in the TeX file, but it should also work with a separate data file.

Score calculation for two different teams

How would i go about counting the scores between C1 and C8 and entering the values into A2 and B2?
a1 = blue
b1 = red
a2 = team blue score
b2 = team red score
between c1 to c8 = winning team & score (NOTE: c1 = $a$1&" 1.25" )
c1 = blue 1.25
c2 = blue 2
c3 = red .5
c4 = draw
c5 = blue 1.5
c6 = blue 1.75
c7 = red 2
c8 = draw
So what I should get is:
A2 should = 6.5
B2 should = 2.5
You can get the total score of the blue team with
=sum(arrayformula(if(left(C1:C, 4)="blue", value(regexreplace(C1:C, "[^0-9.]", "")), 0)))
For the red team, use left(C1:C, 3)="red" in the formula.
The conversion from text to number happens in two steps: regexreplace removes all characters except . and 0-9; then value converts text to number.
It would be better to keep the winning team and their score in separate cells (team in column C, their score in column D), which would simplify the handling of this data: you'd only need =sumif(C1:C, "blue", D1:D).
Taking help of helper columns and without Array formula.These formula can adapt if you change team to Green or any other colour.
Formula in D1:(And Fill down)
=VALUE(RIGHT(C1,(LEN(C1)-LEN($A$1))))
Formula in E1:((And Fill down)
=LEFT(C1,(MIN(FIND({0,1,2,3,4,5,6,7,8,9},C1&"0123456789"))-2))
(And Fill down)
Formula in A2:
=SUMIF(E1:E9,"blue",D1:D9)
Formula in B2:
=SUMIF(E1:E9,"red",D1:D9)

Resources