Count number of occurences in columns and output as chart - google-sheets

I'm coaching a little league team and would like to keep track of how many times a player has played a certain position in a game. I have a table with the available positions as column headers and enter the name of the player who played at that position after each game.
Here is an image of the table:
I'd like to output a chart or table where I can easily see how many times the players have played in the various positions.
How would I do this most efficiently?

Add a column on the left below your existing table, list all players names there (one row each) then use a COUNTIF formula (under Pos A and copied across and down), eg:
=countif(B$2:B$3,$A5)

Related

How to Count cells since the last filled cell in a column, and repeat for each time a cell is filled

I have a tracking spreadsheet to track dry streak calcs for certain drops from a boss in a video game. I want to be able to easily see my dry streaks by having the sheet count the amount if boss kills since the last drop.
I have the following:
=IF(B2="",COUNTBLANK(B2:INDEX($B2:B,MATCH(FALSE,($B2:B=""),0))),"")+1
where column A is the boss kill count, and column B is filled if a drop is received.
the above formula works to an extent of what i want, but the order is upside down. I'd also like it to only show the "count since last drop" when a cell in column B is filled., rather than every cell showing it.
Example sheet
If column A is a sequence of numbers as depicted in the sample you can use formula 1 and formula 2 is stand-alone just based on column B. Please test them out.
formula 1:
=let(a,filter(A2:A,B2:B="drop"),byrow(A2:A,lambda(z,IF(offset(z,,1)="drop",z-xlookup(offset(z,-1,),a,a,,-1),))))
formula 2:
=let(a,filter(row(B:B)-1,B:B="drop"),byrow(B2:B,lambda(z,IF(z="drop",row(z)-1-xlookup(row(offset(z,-2,)),a,a,,-1),))))
Here you have another option that instead of looking for values it just makes a cumulative count.
=SCAN(0,B1:INDEX(B:B,ROWS(B:B)-1),LAMBDA(a,v,IF(v="drop",1,a+1)))
B1:INDEX(B:B,ROWS(B:B)-1) is a replacement for OFFSET so it is a bit more economic in resources
Then you can just hide the values when B is empty:
=INDEX(IF(B2:B="","",SCAN(0,B1:INDEX(B:B,ROWS(B:B)-1),LAMBDA(a,v,IF(v="drop",1,a+1)))))

How to assign weights to counts in Google Data Studio?

I have a data set with events and attendees and along with that also the focus area of the events. All events have a focus area 1 and some have multiple focus areas (2&3).
My goal is to have a tree map or pie chart that shows the number of attendees by focus area. If there are multiple areas then I do not want to count the attendees twice but basically assign a weight of 0.5 (when having 2 areas) or 0.33 (when having 3 areas).
Is there a way to accomplish this in Data Studio (can also include some pre-work in Google Sheets)?
The data has to be rearanged in follwing tables:
Event, Area, Topic, Areavisited, Attendance
Event1, 1, Security, 2, 56
This means you need to unpivot your table. It is possbible to do this in data studio with blend. However, no further field can be added to a blend dataset. Therefore, every calculation should be done in Sheets
Here is an example, how to do this with google sheets using pivot.
First generate a Vistfocus =CountA(B2:D2), counting the focus done at each event. Then do a pivot on that table and add as rows, the event/name and each focus-field. Add a summery row for focus2 and focus3. As Values add the attendance and Visitfocus. In H3 insert following formual:
=If(A3<>"",B3,if(A2<>"",C2,if(A1<>"",D1)))
Thus, the values from focus1, focus2 and focus3 are alternating between the rows. Extend this formula over the whole row. And name it Focus
Import this Sheet in Data Studio and filter all null values in ´Focus`.
https://docs.google.com/spreadsheets/d/1J_HxbqW9FGn1FCI8iOOvvz7u4lrs-YsY1V4R7Yg8DBQ/edit?usp=sharing

Google Sheets: How to make a stacked/aggregate chart

I have made a bar chart which aggregates my data, but is there any way I can split each bar based on the data it is aggregating - similar to how a stacked bar chart would look?
Here is a bad artists impression (thick blue lines mine). The idea is that it's important to know from looking at the graph if I sold 5 at £1, or 1 at £5.
Ideally this would work even if the price for each item is variable, but that is not essential (eg: if there is a 'hack' with hardcoding Apple = 3, I can live with that.)
I'm also fine inputting helper columns etc, within reason, but I would want to be able to easily continue to add things to the list on the left without having to add new helper columns each time (calculated ones are fine, of course.)
Thanks in advance.
UPDATE: With thanks to Kin Siang below, I ended up implementing a slightly modified version of their solution, which I am posting here for completeness.
I added a very large (but finite) number of helper columns to the right, with a formula in each cell which would look for the nth occurrence of the item in the main list (wrapped in an iferror to make the unused cells blank).
=iferror(index(FILTER($A:$B,$A:$A=$D2),E$1,2))
Theoretically it could run out of space one day, but I have made it suitably large that this should not be an issue. It has the advantage over the other solution that I do not need to sort or otherwise manipulate the input range and can continue trickling in data to the main list and have the chart automatically update.
Yes, it is possible to display the chart in your case, however need some data transpose in order to do so, let me show you the example with dataset
Assuming this is your original data:
First sort the data by alphabet, and enter this formula in new column
=if(G39="",1,if(G40=G39,I39+1,if(G40<>G39,1)))
Next add new column for categorical purpose, by using concatenate function
="Price"&I40
In the transform data for chart purpose, enter this formula to split all price into different row, different column for different product
=sumifs($H$40:$H$47,$G$40:$G$47,$A41,$J$40:$J$47,B$40)
After that i select stack bar chart and ensure the price in under series, in case in 23 will have some problem to set price at series correctly, you can use 33 data create stack bar chart and update the data range again, it will work also
Here is the cute chart you expected, accept if help :)
*When certain fruit has less price record, it is advised to fill in 0, as the data table need in same column (see the orange price 3), although I didnot test if blank

How to calculate the number of spaces available in a music class - Google Sheets?

My partner runs music classes for groups of kids and uses Google Sheets as a register. Kids sign up, stop coming, or come back all the time, so we have been hiding the rows in each sheet as and when necessary. We would now like a cell on each sheet (note: each class has it's own sheet) to show the number of spaces available which is updated each time new kid(s) are added or when a row is hidden because kid(s) have stopped attending.
I have tried using the below to show the number of spaces. 16 spaces in each class, minus the number of kids in column B.
=16-COUNTIF(B2:B100,"<>")
The problem is that this calculates the number of spaces with the hidden rows included, throwing up weird results, like minus numbers of spaces available.
How can I add on the number of hidden rows to the above formula?
This solution takes the suggestion by HaPhan and structures it in systematic way.
Consider the screenshot below.
1 - Green Box: there is an extra column ("Status") to record attendance information about a student.
2 - Orange Box: These are the data values for the cells in the "Status" column. All the cells in the Status Column are drop downs. This ensures consistency of spelling, categorisation, etc.
3 - Blue Box: Filters are turned on. In the "Status" column, this allows the questioner to deselect "Finished" and "Stopped" students; which would show only those students who are paid up and attending.
4 - Purple Box: These are totals for the various conditions in the "Status" column. The actual formula is described in column D.
5 - Red Box: A simple summary showing the number of seats in the class that can be sold. Assuming a maximum class size of 16 (manual data entry into cell C6) minus the number of "paid up students (a calculated value from cell C4) gives the number of available seats.
The option to filter rather than hide is significant since "selecting" and "deselecting" is extremely easy, but also automatically covers the entire column. "Hiding" and "unhiding" rows is haphazard; it can be difficult to tell whether one has found all the relevant rows.

Is it possible to generate sprites in a square matrix form?

I want to create a new sprite for my page, and I'm wondering that whether we can create a sprite of 25 images in 5 rows and 5 columns.
Yes, you can generate a sprite sheet in any number of rows and columns you like. You access the particular sprite you want with CSS positioning, so it doesn't matter how many rows and columns you have, as long as you know the coordinates of each, this isn't an issue.

Resources