I'm making a roster of sorts and would like to award points to people's names when they attend events. For example, we use 4 possible responses; Attended, Late, Absent and AWOL. Essentially, Attended will award 2 points, Late will award 1, Absent 0 and AWOL will deduct 2.
We have a main "database" sheet with everyone's information and then a sheet with attendance. I'd like to use QUERY(select where) to determine the right name to add the points to.
I don't fully understand the Query function and its limitations which is why I thought I'd ask here as I'm sure most of you are 10x as knowledgable as I am with Google Sheets. I thought about just using =if(A1='Second sheet'!A2) etc. but remembered about the query function which is able to help automate this process much more.
This is where I'd like the points to be shown on the "Database" sheet.
And this is the data on the "Attendance" sheet.
=ARRAYFORMULA(IF(A2:A<>"", MMULT(IFERROR(
SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C2:D,
"Attended", 2),
"Late", 1),
"AWOL", -2)*1, 0),
TRANSPOSE(COLUMN(C2:D))^0), ))
=ARRAYFORMULA(IFERROR(VLOOKUP(F8:F, Attendance!A:B, 2, 0)))
Related
I have a little spreadsheet I'm creating to track my progress in a game. There are quest chains in the game that earn you points in an event. These are additive when trying to determine your total score in the event. To make data entry cleaner, I have a section with columns of the various levels for each quest chain. They look like the first five columns here:
Quest
Level 1
Level 2
Level 3
Level 4
Levelachieved(dropdown)
Pointsachieved
Apple
25
50
150
Banana
25
50
150
Cantaloupe
25
50
150
Durian
25
100
200
Eggplant
200
Fig
25
50
150
Grape
25
40
100
150
Level 3
165
Honeydew
20
60
150
All of this is on a single sheet - while I understand it may be conventional to put separate calculations on a separate page, I like the convenience of having them all on one sheet so that I can see them all at the same time. That's why I don't think the solution provided in this question is likely helpful to me, as it relates to content on separate sheets. If you'd like to see a screenshot of the actual spreadsheet, here you go.
The other two columns are the ones I'm interested in. I have a Points achieved column where I've been manually adding the points I've earned so far but this is annoying because I have to keep referring back to the game to see what each level is worth since they're inconsistent for each quest chain.
What I'd like to do is have a drop down for the Level achieved, with options for Level 1-4 (I've already done this) and as I play the game, when I complete another level in the chain, I can change the Level achieved dropdown for that quest to the current level. When I do so, this should automatically update the Points achieved to be the total of points from the current and any prior levels.
Example:
I've just completed the Grape quest's third level. As such, I update the Level achieved dropdown to "Level 3" and the Points achieved cell for Grape should now automatically update to 165, which is Levels 1-3 summed (25 + 40 + 100). (This example can be seen in the chart above.)
My problem:
So, I'm not sure what I need to do at this point. I can imagine a few possibilities.
Maybe I can make the calculation simpler by creating a sheet that adds up the totals, so I don't need to set Level 2 as equivalent to the value of Level 1 + Level 2.
Is it possible to have some sort of magic that says Level n = the sum of Level 1 + ... Level n without making a new sheet?
The end result I want is to be able to choose the level in the dropdown and have the Points achieved cell automatically populate with the value of the levels added together. Either way, the crux of my question is - How do I use the value of a dropdown menu to determine the value of another cell? I'm happy to update any of my dropdown or column names as necessary to make it work but I'd prefer to keep everything in the same sheet if possible since there's not actually a ton of content I'm tracking.
Some notes:
While I love spreadsheets, I don't understand the finer magic of them, so if the way I'm using this is unconventional, that's not surprising. I just want to make a useful spreadsheet that I can update easily with data I've already gathered.
I've poked around here on SO and in Google and while I found some possible sources of information, I think I'm struggling to determine whether the solutions they recommend actually address my specific situation sufficiently for me to solve the issue myself.
The final result that you are looking could be achieved with a simple formula, no need to change columns names, extra columns or extra sheets...
... while you keep your spreadsheet simple.
Simple formula
Using the data provided in the question
=SUM(OFFSET(B8:E8, 0, 0, 1, MATCH(F8,{"Level 1","Level 2","Level 3","Level 4"})))
Explanation
{"Level 1","Level 2","Level 3","Level 4"} is an array having the values of the dropdown in the order that corresponds to the columns from left to right.
MATCH is a function that finds the position of the value selected in the dropdown, F8, in the above array.
OFFSET grabs the cells from Column B to the right based on the number returned by MATCH
SUM sums the values of the cells grabed by OFFSET.
Copy the formula from G8 to G2:G9.
To adapt this to your sheet, add the following formula to D2:
=SUM(OFFSET(I2:L2, 0, 0, 1, MATCH(C2,{"Level 1","Level 2","Level 3","Level 4"})))
then fill down.
NOTES:
The formula will return #N/A Error Did not find value '' in MATCH evaluation. if the Level Achieved (dropdown) is empty. To avoid this you could add IFNA setting the second argument as the "default value". If you want to show the cell empty (blank), keep the second argument empty:
=IFNA(SUM(OFFSET(I2:L2, 0, 0, 1, MATCH(C2,{"Level 1","Level 2","Level 3","Level 4"}))), )
If your spreadsheet uses , (commas) as the decimal separator, then replace the , with ; (semicolons).
If your spreadsheet becomes complex, i.e. your sheet becomes very large or you add many sheets and many formulas, then you might require another solution. If that is the case, we will require more details.
References
Using arrays in Google Sheets
you can do:
=SUM(FILTER(B8:E8, B1:E1<=F8))
and the whole column in one go:
=BYROW(F2:INDEX(F:F, MAX(ROW(F:F)*(F:F<>""))),
LAMBDA(x, IFNA(SUM(FILTER(OFFSET(x,,-4,,4), B1:E1<=x)))))
F2:INDEX(F:F, MAX(ROW(F:F)*(F:F<>""))) translates to F2:F8 based on: https://stackoverflow.com/a/74281216/5632629
LAMBDA usage explanation can be found here: https://stackoverflow.com/a/74393500/5632629 in "WHY LAMBDA ?" section
Hoping for a nudge in the right direction.
Summary:
I work a Nursery and have been teaching myself Google Spreadsheets to help with organization. I've come along way but find myself stuck on this function I'm trying to do, and what would be useful throughout my project.
There are multi areas that have different feeding/watering schedules. What I'm trying to achieve is to be able to change the schedule and have it repeat down column B for all the dates in column A.
Here is a example sheet that I set up. This is a small piece of a much bigger project that I have been working on for the past 6 months.
https://docs.google.com/spreadsheets/d/1Mj5X-Xhw6_VCur2hdqeRk1HWvqHSWLg4oCndLubsyAU/edit?usp=sharing
Note: Sometimes, for example, in Area 1, the number of cells to repeat will be 5, and other time it will be 4, depending on the time of year and weather. No matter the number of cells to repeat, the result I am going for is that it is repeated down column B if there is a date in column A
I hope I've explained this correctly.
Thanks in advance for any help I receive.
You can calculate the remainder after dividing the row in A9:A by the number of items in the list in B2:B8 (5 in your example) using Row and Mod. Then use Vlookup to find this value in the corresponding row in B2:B8
=ArrayFormula(if(A9:A="",,vlookup(mod(row(A9:A)-row(A9),counta(B2:B8)),{row(B2:B8)-row(B2),B2:B8},2)))
then copy the formula across to the other columns.
try:
=INDEX(IF(A9:A="",,LAMBDA(x, y, REDUCE(x, SEQUENCE(y), LAMBDA(a, b, IF(b, {a; x}))))
(B2:INDEX(B:B, MAX((B1:B8<>"")*ROW(B1:B8))), COUNTA(A9:A)/COUNTA(B2:B8))))
I've been asked to create a summary for some google form responses, and though I have a working solution, I can't help but feel there must be a more elegant one.
The form collects data related to case checking - every month each team (there's 100+ teams) has to check a certain number of cases based on how many staff are in their team, and enter the results for each case they've checked in the google form. The team that have set this up want me to summarise the data by team, month, and section of the form (preliminary questions, case recording, outcomes, etc). There are 8 sections on the live form, ranging from 1-13 questions, all with Yes/No/NA/blank answers.
(honestly, it's not how I'd have approached setting all this up, but that is out of my hands!)
So they're essentially looking for a live monthly summary with team names down the side, section names along the top, and a %age completed that will keep up with entries as they come in (where we can also use importrange and query to pull the relevant bits into other google sheet summaries, as and when needed).
What I've currently got is this:
=iferror(sum(countifs('Form Responses'!$B:$B,$A3,'Form
Responses'!$F:$F,"Yes",'Form Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$G:$G,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$H:$H,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$I:$I,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$J:$J,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$K:$K,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)))/(countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1))*6),0)
It works, but it feels like a bit of a brute-force-and-ignorance solution. I've tried countifs & array, I've looked a pivot but I can't get the section groups, I've had a play with query but I can't figure out how to ask it to count all Yeses in multiple columns at once.
Is there a more elegant solution, or do I have to resign myself to setting up the next financial year's summaries like this?
Edit:
You can use plain array boolean multiplication to achieve the count, as trues are converted to 1s and false are converted to 0s:
=TO_PERCENT(ARRAYFORMULA(
SUM((f!F1:K="Yes")*(f!E1:E>=B1)*(f!E1:E<EDATE(B1,1))*(f!B:B=A3))/
SUM(6*(f!E1:E>=B1)*(f!E1:E<EDATE(B1,1))*(f!B:B=A3))
)
)
Renamed Form Responses to f
Numerator: SUM of
Question filter (f!F:K =Yes) and
Month filter (f!E:E is within month of B1) and
Team filter(B:B = A3)
Denominator: 6 times the SUM of
Month filter (f!E:E is within month of B1) and
Team filter(B:B = A3)
On this sample sheet that you provided you'll notice two new tabs. MK.Retab and MK.Summary.
On MK.Retab is a single formula in A2 that "re-tabulates" all of your survey data into a format that is much easier to analyze going forward. That tab can be "hidden" on your real project. It will continue to build the 6 column dataset forever. It would be a sort of "back end" sheet, only used to supply data to any further downstream analysis.
On MK.Summary is a single formula in cell A1 that Query's that dataset from MK.Retab and shows the percentage of Yes's by month by section by team in a format similar to what you proposed. I coded it to display the most recent month at the left, immediately to the right of the team names, and to push historical data off to the right. Even though people are often used to seeing time go from left to right, I find that the opposite method nice because it keeps you from having to scroll sideways to see the most recent data. It is very simple to change should you want to by getting rid of the "desc" that you find in the "order by" clause of the query string.
I find this kind of two step solution to problems like your useful, because while the summary migth not be exactly what you want, it's always easier to build formulas and analyses off of the data as laid out in the MK.Retab sheet.
As for the formula in MK.Retab, it is based on a method that I came up with a while back that constructs a large vlookup where the [search key] is actually a sequence of decimal numbers that is built by counting the number of rows in your real data set and multiplying by the number of columns of data that need to be repeated for each row. I built a demo some time ago that I'm happy to share with folks if you want to understand better how it works.
You said that your goal was to understand the formulas so that you could modify them going forward as needed. I'm not sure how easy that will be to do, but I can try my best to answer any questions you might have about the method or the solution generally.
What I can tell you is that some of the formulas are more complicated than they need to be because you just used Q1 Q2 Q3 etc instead of the actual questions. if you had a list of the questions asked somewhere (on some other tab, say), and what you wanted to call/name their corresponding "sections", it would make the formula significantly less complicated. As it stands, I had to use the appearance of the word "Comments", in row 1 to distinguish between where one section ended and another section began. The upside to that decision though, is that the formula I wrote is infinitely expandable to the right. That is, if you were to add another 100 columns worth of questions and answers to the sample set here, the formula would be able to handle that and break it out, so long as there was the word "Comments" between each section.
Hope all this helps.
I am trying to join gained level for names in a list.
Some names are the same person who has changed handle and the scores should be summed.
I have created a sheet to track levels for players in rankings over time.
My implementation is not as clever as I would like it to be.
Also, there is a problem with some players changing names.
Example Sheet
Currently, I have
=SORT(UNIQUE({}))
In order to produce just one of each name in a list
In the cell next to that I'm using
=IFERROR(INDEX(MATCH())) + IFERROR(INDEX(MATCH())) + IFERROR(INDEX(MATCH()))
to the sum of levels for each name across several ranges /sessions.
In the example sheet, N7 and N10 is the same person but my SORT, INDEX, as well as QUERY cannot handle this. I would like to (manually type in the names as strings that belong to the same person) and that the latest handle is the one used in query output together with the sum of all gains.
Any direction pointers or suggestions as to how I could improve my current implementation or even solve the problem I'm having would be appreciated.
=ARRAYFORMULA(QUERY({Ranking!CF4:CF200\ SUBSTITUTE(Ranking!CG4:CG200; "N7"; "N10")};
"select Col2,sum(Col1)
where Col2 is not null
group by Col2
label sum(Col1)'',Col2'Total levels gained since 15 April 2018'"; 0))
Might not suit you (could mean an extra column per month) but one way would be to to use a lookup table. That is enter whatever name suits you, lookup the 'standard' for that name and drive further analysis off that.
I hope you can help me! I work for a company that books Food Trucks for Apartment buildings and each month we send out a form to get which dates and buildings each truck wants to do. What I am looking to do is take One date for one building and show all the trucks that responded in one cell.
I've been lost all day researching a solution for this but I have tried an Index/Match Combo and couldn't get it to work at all. My issue is that we do this every month and I would not like to hard code the formula into it because I just redid the whole spreadsheet to make it more dynamic. This is the last part that I have not been able to figure out.
In the previous version, I used a simple textjoin formula to bring all the trucks into the one cell and had columns that the trucks were hard-coded into. =TEXTJOIN(", ",True,'Named Ranges'!$F$3:$F$63) was the formula I used and each day and building had its own column where the data would go. However, the new version of the data is dynamic and the textjoin formula needs to look for the column with the specific date and building.
Here is the link to the spreadsheet any help you could provide would be awesome!
https://docs.google.com/spreadsheets/d/1RJeTMI1EI8iXr2MV2MmRUU1DZN1irfVgxMU8jlHHKaI/edit?usp=sharing
paste in B11 and drag to the right:
=ARRAYFORMULA(IFERROR(TEXTJOIN(", ", 1, IF(
INDIRECT("Responses!"&ADDRESS(4, MATCH(B8, Responses!$3:$3, 0), 4)&":"&
SUBSTITUTE(ADDRESS(4, MATCH(B8, Responses!$3:$3, 0), 4), 4, ))<>"",
Responses!$B$4:$B, )), "no cars"))