How to create a Google Sheet table of ranked person by date and rank from a list - google-sheets

I have a Google Sheet with daily ranked items expanding with new data everyday in the Raw Data Table A2:C.
I would like to generate a report matrix similar to table in E2:J using one formula so that we don't need to manually copy formulas in each cells in the report table from time to time.
It would be ideal to have one formula at cell E2 (or E3, F1, F2) only that will automatically generate as many rows and columns in the report table based on the data in Raw Data Table. This way, the report table will not needed to be maintained on a daily basis (like copying formula everyday as data expanded).
There are less elegant ways to do it like pre-copy formula into a large number of cells or using Google App Script to generate the table. However, I believe an advance query() or a complex formula mixing query(), filters() and/or arrayformula() can do the job! Just wonder if anyone of the Google Sheets query() expert can help!

try:
=QUERY(A2:C; "select A,max(C) where A is not null group by A pivot B"; 1)

Here's a possible solution:
=ArrayFormula(LAMBDA(dates,ranks,{A2,ranks;dates,IFNA(VLOOKUP(dates&ranks,{A3:A&B3:B,C3:C},2,0))})
(UNIQUE(A3:A),TRANSPOSE(UNIQUE(SORT(B3:B)))))

Related

referencing a grouped date column using GETPIVOTDATA in Google Sheets

I'm doing an analysis of sales data in Google Sheets and I'm building a dashboard with information about different sales reps. I'm trying to use the GETPIVOTDATA function to reference a year-quarter group in my pivot table, but I can't get the function to return the correct value.
In the pivot table, I have specific timestamps grouped by year-quarter and organised as columns. I have the individual sales reps and their teams organised as rows:
[Google Sheets pivot table]. I want to use GETPIVOTDATA to get the number of SQLs for a specific sales rep in a specific quarter.
The function will only return the Grand Total for the sales rep (column F in the picture), or if the Grand Total is disabled in the pivot table, it returns a #REF! error.
I tried many iterations of the GETPIVOTDATA function. I also tried making a helper column in the original data that lists the specific year and quarter instead of the timestamp. Neither of these worked.
I realise that I can use an INDEX MATCH or VLOOKUP instead, but I want to be able to change the pivot table later without having to change the formula.
If anyone knows what I'm doing wrong (or if what I'm trying to do is even possible with a GETPIVOTDATA function) I'd really appreciate advice! I can't seem to figure it out.

How can I concatenate and transpose two ranges of cells in Google Sheets?

I have a Google Form linked to a Google Sheet. It has a number of questions with responses that I need grouped into specific columns. I also need to keep the columns in the order they're in.
I was working with a formula someone helped me with to do one single range:
=ARRAYFORMULA({"Job Responsibilities";IF(A2:A="",,TRIM(TRANSPOSE(QUERY(TRANSPOSE(H2:V),,100))))})
However in the instance I am having problems, I need to group together the answers that are in columns W - AK and also BA - BO into one cell.
I tried something like
=ARRAYFORMULA({"Supporting SAP Stream";IF(B2:B="",,TRIM(TRANSPOSE(QUERY(TRANSPOSE(W2:AK)TRANSPOSE(BA2:BO),,100))))})
or
=ARRAYFORMULA({"Supporting SAP Stream";IF(B2:B="",,TRIM(TRANSPOSE(QUERY(TRANSPOSE(W2:AK, BA2:BO),,100))))})
But that makes an error.
Is there another modification I can make to concatenate and transpose the values in these cells?
Here is a link to a Google Sheet showing most of what I'm referring to. It's from an earlier iteration, so it's not 100% exact with what I said above, but the goal is still the same. In this Sheet, I would like to concatenate what's in Columns U - AG and AU - BF.
Update, based on the data in your sheet:
=ARRAYFORMULA({"Supporting SAP Stream";IF(B2:B="",,TRIM(TRANSPOSE(QUERY({TRANSPOSE(U2:AG);TRANSPOSE(AU2:BG)},,100))))})
Try:
=ARRAYFORMULA({"Supporting SAP Stream";IF(!B2:B="",,TRIM(TRANSPOSE(QUERY({TRANSPOSE(W2:AK); TRANSPOSE(BA2:BO)},,100))))})

Formula for looking up and filtering data from a sheet

I want to do a complex formula using google sheets:
I have a list of place that will be visited by different people.
Some places are not to be visited, marked with /
Some places need to be assigned, marked with ?
Wanted outcome:
A list of cells that changes every day automatic.
An overview of who is going where that day and what needs to be assigned.
So I need a formula that can select a row based on today() and then filter out Persons in that row. Then for each person, another formula that looks up the first row in the table and puts duplicates together.
Example:
Wanted outcome:
Link to excel file, but it needs to work in google sheets too: xlsx
My solution is not the most elegant but it does the job.
First I build a column with date and unique persons or ? in this column:
=unique(sort(transpose(index(A1:H10,match(today(),A1:A10,0)))))
Then I find Places corresponding to these persons (I use filter function for it and then I use textjoin to keep them in single cell).
The formula is copied down as filter function does not accept a range and arrayformula as a filtering criterium.
My solution is available here:
https://docs.google.com/spreadsheets/d/1GTy_UaFP8LbA8OLnEhT_R_twpDCIWCuvQfBAigqtbR0/copy

Google Spreadsheet - VLookup Values From Another Workbook

I have a huge year of data and I cannot add it in 1 spreadsheet because of the limitation on the number of cells per workbook/spreadsheet so I separated the huge data into multiple files by month (January, February, March etc).
In my master file/spreadsheet I needed to use a formula to lookup some values from the master spreadsheet and the problem is that the tables to look into are now in multiple monthly spreadsheets. What is the best formula to look up values in multiple spreadsheets?
After googling for a while I don't have much options, I don't even know what the formula is for using Vlookup to find values in a separate spreadsheet instead of another tab. I tried importrange and it seem to still use the limit even though it's in a different spreadsheet I get error when trying to use it because the data is too large.
So you can use IMPORTRANGE to get the columns needed for the vlookup.
=VLOOKUP(D42,IMPORTRANGE("https://docs.google.com/spreadsheets/d/[sheet_id]","Sheet1!D:ZZ"),1,0)
It's not clear if you added the permission needed to access the other workbook when you use IMPORTRANGE
like this
You can also use IMPORTRANGE in the data parameter QUERY(data, query, [headers])
QUERY is awesome when you know your way around SQL. Google Visualization API Query Language

Setting formula range from first to last populated cell in a column?

For a league I run we keep track of games played and w/l/t and calculate that into a ranking score. The player name is listed in column U and the ranking score in column AD of a fixed table. I then use an array formula to list the players in ranking order in column E (then vlookup to pull in other stats based on the value in E for that row). Specifically I use this formula in column E:
=ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX($U$4:$U$153,MATCH(LARGE($AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),ROW(E72)-ROW(E$4)+1),$AD$4:$AD$153-ROW($AD$4:$AD$153)/COUNT($AD$4:$AD$153),0))), 1, 1)
I need to be able to add players to the table in U:AD without having to edit the formula every time, i.e. from $U4:$U153 and $AD$4:$AD$153 to $U4:$U154 and $AD$4:$AD$154 in all the various places in the formula then copy the new formula all the way down.
Is there a way that I could define the range as $U$4:$U(last populated row) and the same for column AD in the above formula?
I eventually be using this in both Excel and Google Sheets so I would really like to avoid scripting. First I'm looking to solve this for Google Sheets.
Here is a copy of the sheet I am working on.
You could use INDEX and COUNTA
Instead of $U4$U153,
$U4:INDEX(U4:U,COUNTA(A4:A))
The COUNTA portion will give the number of populated rows and feed it into INDEX to give $U4:$U153
The answer for the Google sheet that you shared.
skip to the end for the simple solution
I used the indirect method by entering a formula in E1 that counts the AD column for player stats and adds 3 to get the last row. (I was going create the full range AD4:AD?? but you also have U4:U73 in the formula)
=counta(AD4:AD)+3
I then changed your formula use indirect, indirect("$AD$4:AD"&E$1), to reference the last row number in cell E1 to create the required range.
=iferror(ARRAY_CONSTRAIN(ARRAYFORMULA(INDEX(indirect("$U$4:U"&E$1),MATCH(LARGE(indirect("$AD$4:AD"&E$1)-ROW(indirect("$AD$4:AD"&E$1))/COUNT(indirect("$AD$4:$AD"&E$1)),ROW(E4)-ROW(E$4)+1),indirect("$AD$4:$AD"&E$1)-ROW(indirect("$AD$4:$AD"&E$1))/COUNT(indirect("$AD$4:AD"&E$1)),0))), 1, 1),"")
I discovered by accident that if you remove the ARRAY_CONSTRAIN from your formula and change U4:U73 to U4:AC73 then the formula will populate the scores to the right of your formula where you currently have vlookups. I put an example of this in E4 but note that you will have to delete the vlookup formulas if you want to fill the formula down otherwise it will show REF
I also added iferror so that the formula can be copied to the same row as the end of the "open slots" in column A without showing errors.
Also, I got to this point and was thinking that since you're using Google Sheets, a better way to do this could be to use the QUERY function to pull the data and also sort it using ORDER BY with a single formula in cell E4.
I've not really used the QUERY function but maybe it's time to learn.
EDIT
Turns out it doesn't take much learning
=QUERY(U4:AD,"SELECT U,V,W,X,Y,Z,AA,AB,AC ORDER BY AD DESC")
Put the formula above in cell E4 and delete everything beneath and scores to the right and you're done. you'll notice that there is no indirect because Google understands that you don't want the blank rows.
https://docs.google.com/spreadsheets/d/16IclEmKwDFdInIAZhH2vt-tLJ5pbwX06jv9xrUXwhnY/edit?usp=sharing
Why are you using $ signs around U4:U153,remove $ signs for rows that will give you flexibility while keeping columns fixed.As your drag the formula,the data array will append the newly filled cells or you can create table using Ctrl+T that will automatically expand as you keeping adding data.

Resources