I have table that looks like this:
Name Item1 Date Item 2 Date
John Orange 2/8/2020 Apple 8/8/2020
Bob Banana 6/8/2020
I'm trying to find a way to query that table so that it returns me every item the person has and on what date they got it. Some of the problems I have is that there may be more items added over time so columns would expand.
I have looked into queries but it always forces me to select a column, not a row number. I'm really not sure how to pull this off. I also looked into HLookup but the date field really messes with it.
I am open to changing the structure of the data in the spreadsheet if there is a way to allow to accomplish what I need.
try:
=ARRAYFORMULA(IFNA(VLOOKUP(B13, A1:10, COLUMN(B1:1), 0)))
if you want it in a more readable format:
={ARRAY_CONSTRAIN(
FLATTEN(FILTER(IFNA(VLOOKUP(B13, A1:10, COLUMN(B1:1), 0)),
MOD(COLUMN(B1:1), 2)=0)), (COLUMNS(B1:1)-1)/2, 1),
FLATTEN(FILTER(IFNA(VLOOKUP(B13, A1:10, COLUMN(C1:1), 0)),
MOD(COLUMN(C1:1)-1, 2)=0))}
Related
community!
I have a table of 3 columns in Google Sheets: Date, Name, Amount.
I want to process data from it, so for every date in the list, there will be a full list of participants and amounts.
If there is no amount for specific date and person, it will be "0", or just leave it blank.
In addition, would like to count the percent of the sum of the amount for each person till the date in the corresponding row.
And it should be dynamically updated, so if a new row added with new name or date or both, so new participant will be added to every date in the output table and new full list of participants for the new date created.
For better understanding, here is the example of the data and output tables
What I've tried?
In MS access query it could be done not so hard.
Here I tried to create 2 new lists of unique dates and participants and connect them through use of CONCATENATE, ARRAYFORMULA, then SPLIT and some QUERY. All this through use of helping column of text, which should be edited manually for every new row...
The code in helping column:
=concatenate(arrayformula(if(isblank($F$3:$F),,";"&$E3&","&$F$3:$F)))
Then split code:
=query(arrayformula(split(transpose(split(TEXTJOIN(";",true,$G$3:$G),";",true,true)),",",true,true)),"Select Col1,Col2 where Col2 is not null order by Col1 ASC",0)
But here I stuck...
Want to pull the amounts for every corresponding date and participant, but...
FILTER reaches first, not existent in the original table combination, and doesn't proceed.
QUERY doesn't fetch the data fully automatically for all the list in the output table.
VLOOKUP gives only one row or complete mess, when use it recursively, or error...
So, how can I do this (if it's possible at all) in google sheets, and so all the output will be fully automatically updated?
Thank you very much!
Update - based on comments
I could not figure out a way to make this through one formula. If this works, you can have a hidden column (say H here) that totals the amount for the person till that date using the formula =QUERY(FILTER($E$3:$G, $F$3:$F = F3, $E$3:$E <= E3), "select sum(Col3) label sum(Col3) ''", 0) in H3.
Then in I3 you can find the % of total till date using the formula =QUERY(FILTER($E$3:$G, $F$3:$F = F3, $E$3:$E <= E3), "select sum(Col3) label sum(Col3) ''", 0)/SUMIF($E$3:$E, E3, $H$3:$H).
Both of the formulae in H3 and I3 need to be dragged down unlike the one in E3. Perhaps someone will be able to offer a better solution.
Previous answer
You can try something like this:
In E3 you can have the formula =ArrayFormula({(FLATTEN(SPLIT(REPT(FILTER(UNIQUE(A3:A)&"✦", UNIQUE(A3:A)>0), COUNTA(UNIQUE(B3:B))), "✦"))), (TRANSPOSE(SPLIT(REPT(JOIN("", FILTER(UNIQUE(B3:B)&"◼︎", UNIQUE(B3:B)<>"")), (COUNTA(UNIQUE(A3:A)))), "◼︎"))), (IFNA(VLOOKUP({(FLATTEN(SPLIT(REPT(FILTER(UNIQUE(A3:A)&"✦", UNIQUE(A3:A)>0), COUNTA(UNIQUE(B3:B))), "✦")))&(TRANSPOSE(SPLIT(REPT(JOIN("", FILTER(UNIQUE(B3:B)&"◼︎", UNIQUE(B3:B)<>"")), (COUNTA(UNIQUE(A3:A)))), "◼︎")))}, {A3:A&B3:B, C3:C}, 2, 0), 0))}). It is a little long but fills Columns E through G dynamically.
Then in H3 you can have the formula =ArrayFormula(IFERROR(((IFNA(VLOOKUP({(FLATTEN(SPLIT(REPT(FILTER(UNIQUE(A3:A)&"✦", UNIQUE(A3:A)>0), COUNTA(UNIQUE(B3:B))), "✦")))&(TRANSPOSE(SPLIT(REPT(JOIN("", FILTER(UNIQUE(B3:B)&"◼︎", UNIQUE(B3:B)<>"")), 3), "◼︎")))}, {A3:A&B3:B, C3:C}, 2, 0), 0))/(SUMIF((FLATTEN(SPLIT(REPT(FILTER(UNIQUE(A3:A)&"✦", UNIQUE(A3:A)>0), COUNTA(UNIQUE(B3:B))), "✦"))), (FLATTEN(SPLIT(REPT(FILTER(UNIQUE(A3:A)&"✦", UNIQUE(A3:A)>0), COUNTA(UNIQUE(B3:B))), "✦"))), G3:G))), "")). This one is dynamic as well.
I tried with your data and added a row on my own and it works.
Using Zapier, when someone fills out my Wufoo application form, a line is created with some of the information, including Date Created as well as the locations selected from a checkbox field. On my second sheet, I want to be able to have a total of how many applications have come in just today for each location. I figured the easiest way to do this would be a CountIFs function, but I'm probably wrong.
https://docs.google.com/spreadsheets/d/1mIw_O6KT2QCyKeKmZ4aJ1EHzOkZ4xj49ZyjEMOCwUxA/edit#gid=0
Here is a copy of what I'm building if you'd like to experiment. I'm using =countifs(Sheet1!E2:T1000,"Buford,GA (Atlanta)",Sheet1!E2:T1000,"="&TODAY()) to try to find this, but always get 0 as the result.
try this:
You needed to specify the columns, in your case: E2:E to look up for the name, and S2:S for the date.
=countifs(Sheet1!E2:E,"Buford, GA (Atlanta)",Sheet1!S2:S,"="&TODAY())
You can also use Partial Match in order to use your headers in Sheet2 as the first criteria in your countifs:
=countifs(Sheet1!E2:E,"*"&B$1&"*",Sheet1!S2:S,"="&TODAY())
Then you had a problem of formatting in Sheet1 within the Date's Column (S): your second date in cell S3 was formatted as Date Time, as oppose to your first date in S2 which was formatted as Date only.
Note: The above suggestions are to resolve your personal attempt, otherwise they are other ways of achieving what you're looking for.
UDPATE (ALTERNATIVE SOLUTION):
you could use the following QUERY which summarize everything within a table and sort it in descending order:
= {"Names","Count";
ARRAYFORMULA(
SORT(
TRANSPOSE(
SUBSTITUTE(
QUERY(Applications!D1:T,
"Select Count(D),Count(E), Count(F), Count(G), Count(H), Count(I), Count(J),
Count(K), Count(L), Count(M), Count(N), Count(O), Count(P), Count(Q), Count(R), Count(S) where T = date '"&TEXT(today(),"yyyy-mm-dd")&"'
"),
"count", "")
),
2, 0)
)
}
Sounded so simple! I have a sheet called "Account", containing a running balance in column "G" and I have another sheet called "Performance", with a table which lists historical dates and column "D" needs to lookup the account balance on the day stated in column "A".
"Account" Sheet
"Performance" Sheet
For example, Performance!D2 should be "210,000.00".
Performance!D7 should be "110,000.00".
Performance!D9 would be "40,000.00".
To make this slightly more difficult I like to put formulas into the heading row as arrayformulas where possible, to avoid problems when copying and pasting data or adding new rows, etc.
I've tried many different possibilities and nothing has worked. I'm currently trying to make the following formula work, which is in Performance!D1.
=ARRAYFORMULA(if(row(D1:D) = 1, "Cash", VLOOKUP(A1:A, MIN('Balance'!A4:A <= A1:A), 7, 1)))
I've also tried some solutions involving MATCH(), FILTER(), VLOOKUP() and LOOKUP() but so far no cookie!
this should work:
=ARRAYFORMULA({"Cash";if(A2:A="",,VLOOKUP(A2:A, SORT('Account'!A4:G),7,TRUE))})
VLOOKUP(...,true) returns the value associated with the closest match in the first column without going over. Provided that the range into which you're doing the vlookup is sorted by the first column of that range.
I have a CSV file that I'm pulling from a database. It's in an awkward layout so I need to reorganise it and display the result in a separate sheet.
Here is a dummy example of the data structure I get.
https://docs.google.com/spreadsheets/d/1sTfjr-rd0vMIeb3qgBaq9SC8felJ1Pb4Vk_fMNXQKQg/edit?usp=sharing
It looks like that. The database grows every day by date and sometimes countries so I need to account to that in my formula.
I need to pull data per each country and display it by date.
I don't need data from Column A, C and D. And when there are multiple states I need to sum them up in one column.
It should look like this and keep growing downwards. I'm gonna use this table for a graph chart
What I've tried so far
=TRANSPOSE(QUERY(IMPORTRANGE("url_to_a_separate_sheet_where_I_importing_a_row_csv_file", "CSV-source-sheet!A1:500"), "SELECT * WHERE Col2='Germany'"))
This works, kinda. But pulls in unnecessary columns and I can't figure out how to sum countries with multiple states. When I add select sum(*) it gives me a big and long error. I assume it might be because of unnecessary columns that the formula cant sum up and I don't know how to omit them. I'm stuck
I tried offset and skipping no luck. Any ideas?
try:
=ARRAYFORMULA(TRANSPOSE(QUERY({Sheet2!B:B, Sheet2!E:BE},
"select Col1,"&TEXTJOIN(",", 1,
"sum(Col"&ROW(INDIRECT("Sheet2!A2:A"&COUNTA(Sheet2!1:1)-5))&")")&"
where Col1 is not null
group by Col1
label Col1'Date'", 1)))
spreadsheet demo
I need to make a list of which student is taking what kind of exam on which date and time.
The sheet with all the data looks like this:
This is per student but not per date.
I would like to have a tab per exam AND time. So exam Dutch is taken at 06-06-2019 at 10:00h, 12:00h and 14:00h. Tabs should be like: tab1 all students that take exam Dutch at 06-06-2019 10h, tab2 all students that take exam Dutch at 06-06-2019 12h, etc.
The order of columns can't change because the sheet as in the example is also generated with formulas etc. from other sheets.
I tried the VLOOKUP formula but this can't search on the left. I have absolutely no idea how to solve this.
I'm not looking for a ready to use answer. Just push me in the right direction.
You could use filter() or query().
Assuming 'achternaam' in column A and 'exam Dutch' is in column E, you can try
=query('SheetwithData'!A:E, "Select A where E contains '06-06-2019 10:00'", 1)
Replace the sheet name with the actual sheet name.