I have a grid of cells in Google Sheets:
A1 displays the quantity of product code "ABC" in B1, then C1 displays the quantity of the product code "DEF" in D1, it then repeats on the next row for the next customer and so forth.
I am attempting to summarize all of this area at once at the bottom, using some kind of COUNT formula, but haven't been able to figure out how yet.
=QUERY({A:B;C:D},
"select Col2, sum(Col1)
where Col1 is not null
group by Col2
label sum(Col1)'Sumary', Col2'Item'")
=QUERY({A:B;C:D},
"select Col2, count(Col2)
where Col2 is not null
group by Col2
label count(Col2)'Count', Col2'Item'")
Related
I need a multi-level nested pie chart in google sheets.
To show number sums in categories and sub-categories. Can use code or just formulas.
Or if a system similar to google sheets already has a easy configurable nested pie-chart I can consider using it.
Here is a sample sheet with 2 charts I want to combine:
https://docs.google.com/spreadsheets/d/1TvOf_tRNFS4zqbYR8EMGfTH1krI_iX9resrQ_AwmGZ8/edit?usp=sharing
It can be similar to the one here, but with sums instead of counts:
Three Google Sheets' data graphs (pie charts) in one graph
Or a D3 Sunburst Partition.
dynamic fx:
=ARRAYFORMULA({TRANSPOSE(QUERY({A1:C}, "select sum(Col3),Col1 where Col1 is not null group by Col1 label sum(Col3)'Base Pie'"));
{"♀", IFERROR(1/(1/TRANSPOSE(MMULT(TRANSPOSE(IF(SEQUENCE(COUNTUNIQUE(A2:A))<SEQUENCE(1, COUNTUNIQUE(A2:A)),
QUERY({A2:C}, "select sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''"), )*1), SEQUENCE(COUNTUNIQUE(A2:A), 1, 1, )))));
QUERY(QUERY({A2:C, ROW(A2:A)}, "select Col2,max(Col3) where Col3 is not null group by Col4,Col2 pivot Col1"), "offset 1", )};
{"♂", IFERROR(1/(1/TRANSPOSE(MMULT(TRANSPOSE(IF(SEQUENCE(COUNTUNIQUE(A2:A))>SEQUENCE(1, COUNTUNIQUE(A2:A)),
QUERY({A2:C}, "select sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''"), )*1), SEQUENCE(COUNTUNIQUE(A2:A), 1, 1, )))))}})
the formula takes data in A:C range and creates all necessary steps, columns and rows that will feed pie charts.
rows labeled ♀♂ serve as pie chart ratio correctors
column E can be used as a subcategory labeling system if needed
in the same manner row 3 can be used as labels for base pie
first, we create a base pie chart (from the black row) which will serve as background:
next, for each colored column we create a separate pie chart that we overlay on top of the base pie chart. note that colors and sub-colors needs to be selected manually for each slice by double-clicking a given slice and selecting either color or none in the case of ♀♂ slices
and repeat for the next column...
demo spreadsheet
E2:
=QUERY({A2:C}, "select Col1,sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''")
G2:
={FILTER(B2:C, A2:A=E2); "", SUM(FILTER(B2:C, A2:A<>E2))}
I2:
={"", SUM(FILTER(C2:C, A2:A=E2)); FILTER(B2:C, A2:A=E3); "", SUM(FILTER(B2:C, A2:A=E4))}
K2:
={"", SUM(FILTER(B2:C, A2:A<>E4)); FILTER(B2:C, A2:A=E4)}
demo sheet
I understand that for COUNTIFS, you need to have ranges that are the same size and shape. However, I need one condition to be that the ID# in the cell matches the ID # in a one column range AND that the age in the cell matches the age value in a five column range. How can I work around this?
Sample sheet: https://docs.google.com/spreadsheets/d/1i6qFmJ1t7yDpGVSO8YOPnWqW_OZEz6fv4shTOBO-q3M/edit?usp=sharing
In cell A7 of the 'Analysis' tab I entered
=query(ArrayFormula(regexreplace(split(flatten(Masterfile!A2:A&"_"&Masterfile!B2:F), "_")&"", "\d+\smonths", "0")), "Select Col1, count(Col1) where Col2 <>'' group by Col1 pivot Col2")
See if that works for you?
I have a table for employees and dates, I want to find out how many cases they solved on an exact date. I tried using a query but it's not working for me as its a new challenge for me to make a query that works based on the horizontal and vertical values. here is an example:
https://docs.google.com/spreadsheets/d/19x2jGYM7xt_WIZN_OGPwTe_7q26Jj57l9Z0PUmSv0I8/edit#gid=0
try:
=QUERY(TRANSPOSE(QUERY(TRANSPOSE(A1:H),
"where Col1 matches 'Day|"&I3&"'", 0)),
"select sum(Col2)
where Col1 ="&DATEVALUE(I2)&"
label sum(Col2)''")
I have three google sheets of data in one spreadsheet. these sheets containing the data of ABC Town students. ABC Town has 3 Streets called Street 1, Street 2 and Street 3.
Street 1 has 10 Students in different grades.
Street 2 has 6 Students in different grades.
Street 3 has 2 Students in different grades.
Every sheet has Students Grade summary Pie Graph. Now What I need is,
I have to combine these three pie charts into one chart to get a final summary of three sheets. how can I do this? Please.
This is my spreadsheet: https://docs.google.com/spreadsheets/d/1NmCSRPaoGCpuyfxv24z2-M8TNktBjHNt7BoaMF6LCJY/edit?usp=sharing
explained in image:
or maybe you just want to combine all 3 charts (?) like:
demo spreadsheet
if you map out your data the right way you can create pie chart with sub-slices for each of your three pie charts and then you will just layer them. here is an example:
your dataset of A1:C is not in "good" shape for creating a chart, so first, you will need to re-shape it by adding few formulas in auxiliary columns which you can hide when done
in cell E1 paste this formula and create a base pie chart. this will create even ratio between Libaries. select primary color for each libary and maximze chart style
={"Libaries"\""; {TRANSPOSE(SPLIT(REPT(1&" ";
COUNTA(UNIQUE(FILTER(B2:B; B2:B<>""))));" "))\
UNIQUE(FILTER(B2:B; B2:B<>""))}}
if you got #ERROR! paste this into E1 cell:
={"Libaries",""; {TRANSPOSE(SPLIT(REPT(1&" ",
COUNTA(UNIQUE(FILTER(B2:B, B2:B<>""))))," ")),
UNIQUE(FILTER(B2:B, B2:B<>""))}}
paste this formula in G1 cell to create labels:
=ARRAYFORMULA(SPLIT(JOIN("×";
TRANSPOSE(REPT(UNIQUE(FILTER(B2:B&"×"; B2:B<>"")); 2))); "×"))
then paste this formula in G2 to create dataset for 2nd chart:
=ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C);
"select count(Col3), Col3
where Col1 is not null and Col2='"&G1&"'
group by Col3
label count(Col3)''"; 0))
after this you will need correction formula which can correct position of the first set of pie slices. paste this in G6 cell and create 2nd pie chart from range G2:H. then play with colors and set color of the correction pie on None
=IF(SUM(ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C);
"select count(Col3)
where Col1 is not null and Col2='"&G1&"'
group by Col3
label count(Col3)''"; 0)))>3;
SUM(ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C);
"select Col3, count(Col3)
where Col1 is not null and Col2='"&G1&"'
group by Col3
label count(Col3)''"; 0)))*2; 6)
when done, overlay 1st chart with 2nd chart
then paste this formula in i4 cell (this will be dataset for 3rd chart)
=ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C);
"select count(Col3), Col3
where Col1 is not null and Col2='"&I1&"'
group by Col3
label count(Col3)''"; 0))
next you need correction again. this time twice. paste this formula in i2 and i7
=SUM(ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C),
"select Col3, count(Col3)
where Col1 is not null and Col2='"&I1&"'
group by Col3
label count(Col3)''", 0)))
now you can construct 3rd pie chart from range i2:J. again play with colors and hide correction slices. when done overlay it on top of 1st and 2nd chart
when done paste this formula in K4 cell (this will be dataset for the 4th pie chart)
=ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C);
"select count(Col3), Col3
where Col1 is not null and Col2='"&K1&"'
group by Col3
label count(Col3)''"; 0))
and again you need to correct the position with this formula pasted in K2 cell
=IF(SUM(ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C);
"select count(Col3)
where Col1 is not null and Col2='"&K1&"'
group by Col3
label count(Col3)''"; 0)))>3;
SUM(ARRAYFORMULA(QUERY(TO_TEXT($A$2:$C);
"select Col3, count(Col3)
where Col1 is not null and Col2='"&K1&"'
group by Col3
label count(Col3)''"; 0)))*2; 6)
create 4th pie chart from range K2:L, play with colors, hide correction slice, possition it on all previous charts
if you want to put up some labels then you can insert drawings and overlay it once again
demo spreadsheet
Let's say I'm using ARRAYFORMULA to generate values (whitespace is for readability):
=ARRAYFORMULA({
Sheet1!A1:C,
Sheet1!A1:A * Sheet1:B1:B,
Sheet1!A1:A * Sheet1:B1:B + Sheet1!C1:C
})
The first 3 cells are directly from Sheet1.
The 4th cell is a formula using the values from the first 2 cells.
The 5th cell is a formula using the value from that 4th cell, and then adding the 3rd cell.
Instead of needing to re-calculate the 4th cell in the 5th cell, is there a way to reference the result of the 4th cell in the 5th cell?
No, there is no way to reference a column of virtual array {} within the same array. Two workarounds are:
Create the column A*B+C using a second array formula, which references the output of the first
or,
Wrap the output of arrayformula in a query which can reference the columns as Col1, Col2, ...
Example:
=query(arrayformula({A1:C, A1:A*B1:B}), "select Col1, Col2, Col3, Col4, Col4+Col3 label Col4+Col3 ''", 0)