I know how to use Subtotal when I only need a breakdown by 1 column. But I have a sheet with 2 sort level. I need to get counts based on values for each of the second level sort. To clarify, I need something like this: assuming Col A is primary sort and Col B is secondary.
A B Count
Walmart Shoes 20
----------
Walmart Socks 10
Walmart Shirts 25
Target Socks 50
Target Jeans 5
Target Shirts 10
etc... (Not sure how to make this prettier(more readable).
Can the Subtotal function do this or do I have to get into Pivot Tables (Group, etc)? Thanks in advance?
Seems like this would be a situation that would call for a Pivot Table.
To create the pivot table select one of the cells in the raw data (Columns A through C in the picture). Then select the Insert Tab >> PivotTable >> PivotTable. You'll have the choice of putting the PivotTable on another worksheet or the one that contains the data (as shown).
Check A, B and C as seen in the picture, the choice of area should be done automatically, however if one of them does not automatically appear in the correct area (as shown) you can drag it.
Under PivotTable Tools select the Design tab and then Report Layout and Show in Tabular Form.
To the left of Report Layout is Grand Totals which you would turn off to make the pivot table look more like the table in your example.
To the right of Grand Totals is Subtotals which you would also turn off by choosing Do not show.
If it is important that Walmart precede Target, select the down arrow in PivotTable cell containing A (E2 in the picture), and sort Z to A.
Hope this helps.
Related
I'm trying to work out a function in a Google Sheets cells to look at a column then search current row and "above" the current row to find a non number value (text).
I have data that in two columns B (item code or category) & C (item description).
I need another column to contain the categories for each item - column D. I'm looking for a formula for this column, ideally an Arrayformula as the data can change, there can be multiple items per category, some might be only 1 item, some might be 100 items per category. The arrayformula in column D will get the category from column B if it is not a number.
B column - categories and item codes, C column - item descriptions, target is D column a copy of the categories from column B.
I've tried this numerous times and usually give up, do it manually but it becomes teadious quickly. Looking forward to any help that might come from this! thanks.
In D2 try
=Arrayformula(if(isnumber(B2:B), vlookup(row(B2:B), filter({row(B2:B) , B2:B}, istext(B2:B)), 2), B2:B))
and see if that works?
Try in D1
={"Category";ArrayFormula(lookup(row(B2:B),row(B2:B)/if(isnumber(B2:B),0,1),B2:B))}
OS: Windows 10
Here's the basic idea:
I have a list of foods that are on the left side, and when I decide which foods I want, I then decide what order I want them in. After they are in the right order, G7-J7 (Linked Foods) should automatically place a hyperlink based on what food I selected in the Order of Food. How it pulls these links should be from the List of Foods. Then, at the bottom, there are 4 images that will automatically be shown based on what link is in the Linked Food boxes.
Basically, what I did, was I made the Linked Food 1 formula =IF(G3 = "Ramen", D2, "No Link Found").
And then for the Food 1 image, I did =iferror(arrayformula(image(G7)),"")
The image should automatically be there for whatever link I put in the G7 box now, but the G7 box is the main issue I'm having.
Everything works, but this is only an example. In my REAL project I'm doing, I have tons and tons of "foods" and I can't just put =IF(G3 = "Ramen", "Lemonade", "Tofu", "Fruit Punch", ...and the hundreds of others.
SO...What I'm wondering, is if there's an easier way to make these links automatically change, without having to manually put every single item from the List of Foods into the formula.
Any help is appreciated!
It is somewhat unclear if the question is asking this for google docs or Excel, but the solution is basically the same either way.
What you want here is called "VLOOKUP". You will be replacing this line:
=IF(G3 = "Ramen", D2, "No Link Found")
with
=VLOOKUP(G3, C2:D8, 2, FALSE)
This will take the value of cell G3 (Ramen in the example case) and search the range of C2:D8 (all the cells on the left of your table) until it finds it. Once it does it will go to the second column of the range (C = 1, D = 2) and take the matching cell value. The FALSE at the end has to do with sorting but shouldn't play a role here.
Note that your range needs to be the entire size of your foods list so change that D8 to DX where X is the size of your list in rows.
You can read the full syntax for VLOOKUP at: https://support.google.com/docs/answer/3093318?hl=en
I am trying to set up a spreadsheet to summarise the amounts of money I transfer between four bank accounts. In the attached spreadsheet, I will manually put in the transfers I make between the different accounts (i.e., Everyday, Holiday, Emergency, Investments) in columns A, B, C, and D. In column A, you double-click a cell to add in a date, while columns B and C use a drop down box to choose accounts.
What I would like to do is have the information in these four columns populate the table on the right.
I've named columns B and C as "OUT" and "IN", respectively. For example, in my sheet, the second row means that on the 8th April, I'd taken $500 OUT of the Everyday account and put it IN the Holiday account.
So for the table on the right, I'd like for it to give me the totals for all the money I've transferred IN and OUT for each specific account for each specific month. Do you know what formulae I could use to do this if it's possible?
An example of my spreadsheet is here: https://docs.google.com/spreadsheets/d/1azNw6m7f3x7WhwEP9WXolCzfTE9dccj9wjs0qPwD-FY/edit#gid=2056599600
I have tried to use VLOOKUP and SUMIFS.
paste this into H3 cell and drag to the right - then drag down:
=IFERROR(SUM(QUERY({$A:$D},
"select Col4
where Col"&IFS(H$2="OUT", 2, H$2="IN", 3)&"='"&IF(H$1="", G$1, H$1)&"'
and month(Col1)+1="&MONTH($G3&1), 0)))
and for totals row paste this in H15 cell and drag to the right:
=SUM(H3:H14)
demo spreadsheet
Data:
Row A
House;Farm;Zoo
House;Farm
House, Zoo
Row B
Dog;Cat;Lamb;Tiger
Dog;Bunny;Chicken,Fish
Lizard;Cat;Cow
Table 1
House
Dog
Cat
Mouse
Fish
Chicken
Table 2
Zoo
Tiger
Bear
Seal
Table 3
Farm
Bunny
Duck
Lamb
Cow
Horse
Question In Google Sheets
Ok I am trying to figure out how to calc the Column A based on what string is in the Column B The definition of what is in the B Column comes form the three tables in the bottom. Any help would be wonderful!
So here is one way. In some other region of the table, from which you will copy column A at the end, set up the following expression for each row, starting in column B. I am imagining your =original list with column A to be calculated starts in row 1 (so B1 is dog, C1 is cat, and so on).
Suppose your 3 tables sit in rows 6 to 8.
Some rows below, in column A, paste the following:
=IF(ISBLANK(B1),"",IFERROR(QUERY($A$6:$F$8,"Select A where "&"(B = '"&B1&"') OR " & "(C= '"&B1&"') OR "& "(D= '"&B1&"') OR "& "(E= '"&B1&"') OR (F='"&B1&"')")))
Let me unpack that. If the entry is blank, we will leave the corresponding item empty. Similarly, if our query fails, leave it blank. But the query says look in the tables, find the match, and give us the corresponding column A value.
Drag this formula right 3 more columns for a total of 4, which is the longest length of animal list we're trying to cover. You end up with the corresponding places (if any), cell by cell. Also drag this formula down 2 more columns so you get each row.
Clinch by doing the following one column further over. I was in row 10, your row may vary.:
=textjoin(";",true,transpose(unique(transpose(A10:D10))))
this puts togethjer a list of the unique, noempty, values, separated by semicolons.
Drag this down 2 columns, and then go back let you A1=the top corresponding entry, drag down, and you're set.
EDIT: The above assumes Dog, Cat, Lamb, and Tiger are spread across cells in columns B, C, D, and E. If not and they are in just one cell, you may need something like in the C column =split(B1,";") and to adjust columns in my formulas over by 1.
We have asked users:
What to do with the money?
[ ] paint the bridge
[ ] rebuild the school
[ ] keep the money
[ ] Other : [____________________]
Here is the spreadsheet with their answers:
A B
1 Name Choices
2 Lilia paint the bridge, rebuild the school, keep the money
3 Paul rebuild the school, paint the bridge, do something else
4 Margerite keep the money, I don't know, do what you want
5 John paint the bridge
...
800
I want a formula that output the number of official choices (excluding other) picked per user.
With the first 4 rows of data, the formula would output this table:
D E
Nbr of choices a user made Frequency (Nbr of users who made these choices)
0 0
1 2
2 1
3 1
Couldn't find a way to get this right from a single formula. For a starter, I wanted to split each line (of B2: B) by "," but couldn't find a way to apply a fn (split) to each line in an formula...
Even with 800 rows of data (B2:B), the resulting table (D2:E5) would always be 4 rows long plus titles (and two column wide)
I could do this in C2, and replicate manually with the "+" corner icon...
=countif(B2;"*rebuild the school*")+countif(B2;"*keep the money*")+countif(B2;"*paint the bridge*")
And then do in E2:
=arrayformula(countif(C2:C;D2:D5))
But I'd like to generate the table of frequencies in one formula, without any manual action (without C column).
So I am looking for a way to "map" the first function to each row, put this in the second fn.
ANSWER by Akshin Jalilov EXPLAINED
This is the answer by Akshin Jalilov, but shorter (and with international notations)
=ARRAYFORMULA(COUNTIF(ARRAYFORMULA(IF(B2:B="";;COUNTIF(ARRAYFORMULA
(IFERROR(IF(FIND("paint the bridge";B2:B);Row(B2:B);0)));"="&row(B2:B))
+COUNTIF(ARRAYFORMULA(IFERROR(IF(FIND(
"rebuild the school";B2:B);Row(B2:B);0)));"="&row(B2:B))
+COUNTIF(ARRAYFORMULA(IFERROR(IF(FIND(
"keep the money";B2:B);Row(B2:B);0)));"="&row(B2:B))));"="&D2:D5))
Step1:
IF(FIND("rebuild the school";B2:B);Row(B2:B);0)
This means, for each row (B2:B) find "rebuild the school". If you find it, return the number of the row, otherwise, return 0.
Step2:
=ARRAYFORMULA(IFERROR(Step1))
Wrap this in an ARRAYFORMULA so that you return the results for each row.
I think IFERROR is there to prevent an error from stopping the process.
Step3:
=ARRAYFORMULA(IF(B2:B="";;COUNTIF(ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge";B2:B);Row(B2:B);0)));"="&row(B2:B))+countif(Step2)+countif(ARRAYFORMULA(IFERROR(IF(FIND("keep the money";B2:B);Row(B2:B);0)));"="&row(B2:B))))
This will count valid votes made by each users. This is equivalent to C2 formula referred in my manual process. But is it now part of a single global formula.
Step4:
Lastly, the rest of the formula counts frequencies of each voting count possibilities.
I know this formula is large but this is the closest I got to what you want.
Now to make it easy, name your responses range "Responses". I assume it is B2:B.
Here is the formula:
=ARRAYFORMULA(Countif(ARRAYFORMULA(IF(Responses="",,COUNTIF(VLOOKUP(row(Responses),({ARRAYFORMULA(Row(Responses)),ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("rebuild the school",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("keep the money",Responses),Row(Responses),0)))}),2),"="&row(Responses))+COUNTIF(VLOOKUP(row(Responses),({ARRAYFORMULA(Row(Responses)),ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("rebuild the school",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("keep the money",Responses),Row(Responses),0)))}),3),"="&row(Responses))+COUNTIF(VLOOKUP(row(Responses),({ARRAYFORMULA(Row(Responses)),ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("rebuild the school",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("keep the money",Responses),Row(Responses),0)))}),4),"="&row(Responses)))),"="&D2:D5))
Here is an example if how it works. I am not sure which one exactly you wanted so added both