So, I have an imported sheet with colums like so...
Name
SAT1045
SAT1200
Dave
0
1
Angela
0
1
Stuart
1
0
From this I need to generate attendance lists displaying the times (SAT1045) followed by those attending. Those attending have a 1 in that column. So as a example:
SAT1045
Stuart
SAT1200
Dave
Angela
The other trick is there are multiple days and times, so I have used Data Validation to populate a dropdown on a fresh sheet. So the chosen date would populate the list below it.
I just don't know what Query or Lookup function to use to strip the data from the import as there is also a lot of nonsene data in the import between the Names and the dates.
Can anyone help?
I have tried numerous levels of Query's and Lookups but my head just can't get around this one
I would recommend you to use a second sheet for the attendance.
If the Name cell in your exemple is A1, you cvan have someting like this in your second sheet:
In A1 (second sheet) :
=Sheet1!B1
this will set the header at the corresponding time
In A2 (second sheet) :
=QUERY(
Sheet2!$A$1:$C$4,
CONCATENATE("select A where ",SUBSTITUTE(ADDRESS(1,COLUMN(B2),4),1,""),"=1")
,0
)
this will get the names for the time set in the first row.
Than tou only hace to drag those to for every attendance to get.
Edited to adjust to OP's comment
=QUERY(
[table of time and 0/1],
CONCATENATE(
"select A where ",
SUBSTITUTE(
ADDRESS(
1,
COLUMN(
INDEX(
[Row with all times],
match(
[Reference of the cell with the dropdown],
[Row with all times],
0
)
)
),
4
),
1,
""
),
"=1"
),
0
)
this formula here allow you to get the attendants based of the time in the cell above it.
So, from the left to the right :
match here will look through the different time based on the selected one in the cell above, and will return the reference of the cell;
The whole part Substitute(Adress(Column(Index()))) will return the letter of the column in wich the selected tim is. this allow to have a valid Query as it requiress the letter of the column to work;
And finally the Query returns every name where the value is 1 in the column corresponding to the chosen time
The values of [Row with all times] should always be the same. In your case, either 1:1 or $AC$1:$AP$1. In the first case it's just that if you add a row for a new time it'll take it into acount
I am trying to SUM every number in a range on a different sheet. This range is dictated by an employee number, as well as the year; it changes for each employee and it also changes every year.
So I need the sum function to work like this:
=sum(first cell:second cell)
With the cells being variable with each employee.
I had used the ADDRESS function to obtain the cell values, but it put the sheet name between apostrophes, e.g. 'sheetx!'!A1 , which I thought caused the sum function to return an error.
To test this, I made a test SUM function using input from the CELL function, which returns the sheet value without apostrophes (e.g. sheetx!A1). I still got an error.
What am I doing wrong?
Edit: filter did not seem to work for me, but the index and indirect combo worked like a charm
Functions like INDEX, OFFSET,INDIRECT return the value as well as the range reference. So, you could use something like
=SUM(
INDEX(Sheetx!A:A,1,1)
:
INDIRECT(ADDRESS(1,2,1,1,"Sheetx"))
)
Note however, INDEX and OFFSET are preferred over INDIRECT as string ranges are better avoided to help internal optimization of spreadsheet.
Agree with #Harun24hr, try with the following:
=SUM(
FILTER(
FILTER( history_earnings!1:1000, history_earnings!A:A=B2 ),
MATCH( COLUMN( history_earnings!1:1000 ),
FILTER( COLUMN( history_earnings!1:1 ), history_earnings!1:1=A1 ),
0
)
)
)
you use ADDRESS that returns a string and then you join your two strings with a colon : but that is still a string not a valid range. try:
=SUM(INDIRECT("history_earnings!"&
ADDRESS(MATCH(B$2, history_earnings!$A:$A, ),
MATCH($A$1, history_earnings!$A$1:$Z$1, ))&":"&
ADDRESS(MATCH(B$2, history_earnings!$A:$A, ),
MATCH($A$1, history_earnings!$A$1:$Z$1, )+11)))
also, in your question, you mention: 'sheetx!'!A1 which is also wrong due to two exclamation marks ! correct being: 'sheetx'!A1 unless your sheet is called sheetx!
I am trying to grab advertising expenses for the day on the basis of country groups.
The date, and country for the record are in columns I, J and G respectively.
I am doing a VLOOKUP that references a sheet called advertising,
with the search key being a date and month together, and picking up the value column based on the country.
Then in order to average it out, I am dividing this lookup, which gives me the ad spend for a set of countries by the number of records for that date, month and country.
=(IF(OR(G4="Spain",G4="Portugal"),VLOOKUP(I4&J4,Advertising!$A$3:$AK,32,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Spain","Portugal"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Spain","Portugal"}),0),
IF(G4="France",VLOOKUP(I4&J4,Advertising!$A$3:$AK,33,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"France"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"France"}),0),
IF(G4="Italy",VLOOKUP(I4&J4,Advertising!$A$3:$AK,34,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Italy"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Italy"}),0),
IF(OR(G4="Belgium",G4="Netherlands"),VLOOKUP(I4&J4,Advertising!$A$3:$AK,35,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Belgium","Netherlands"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Belgium","Netherlands"}),0),
IF(G4="Sweden",VLOOKUP(I4&J4,Advertising!$A$3:$AK,36,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Sweden"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Sweden"}),0),
IF(G4="United Kingdom",VLOOKUP(I4&J4,Advertising!$A$3:$AK,37,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"United Kingdom"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"United Kingdom"}),0),
VLOOKUP(I4&J4,Advertising!$A$3:$AK,31,0)*IF(COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"})>0,1/COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"}),0)
)))))))
Unfortunately, this is returning an error for me.
As you can see, I have an IF clause to avoid division by zero.
However, I have somehow convinced myself that the error is being reurned in the averaging (i.e. division with the COUNTIFS) process, not in the VLOOKUP. I do believe my COUNTIFS are illegitimately and unexplainably returning zero.
e.g. for row 4 in the main sheet, which I have posted above,
=COUNTIFS(I$4:I,I4,J$4:J,J4,G$4:G,{"Germany","Austria","Bulgaria","Croatia","Cyprus","Australia","Denmark","Estonia","Finland","Greece","Hungary","Ireland","Latvia","Lithuania","Luxembourg","Malta","Norway","Romania","Russia","Slovakia","Slovenia","Switzerland","UAE"})
returns a zero. When I test it out with fewer countries, always including Austria, sometimes it returns zero, sometimes 1.
A sample sheet is at https://docs.google.com/spreadsheets/d/1YgK_D7FaTWtKcSts2uDiG7jlTRx2_IGrJ41wZr2qyak/edit?usp=sharing
P.S. I do not have enough reputation, but I would request one of the seniors to add "countifs" tag.
try in row 4:
=INDEX(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!B3:AK},
MATCH(G4:G, Advertising!A1:1, ), )))
update:
=INDEX(IFERROR(1/(1/(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!AE3:AK}, MATCH(IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )), Advertising!AD1:AK1, 0), ))/
COUNTIFS(I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )), I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G,
{{"France";"Germany";"Austria";"Bulgaria";"Croatia";"Cyprus";"Australia";"Denmark";"Estonia";"Finland";"Greece";"Hungary";"Ireland";"Latvia";"Lithuania";"Luxembourg";"Malta";"Norway";"Romania";"Russia";"Slovakia";"Slovenia";"Switzerland";"UAE";"Italy";"Belgium";"Netherlands";"Spain";"Portugal";"Sweden";"United Kingdom"},
{"France";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Germany";"Italy";"Netherlands";"Netherlands";"Spain";"Spain";"Sweden";"United Kingdom"}},
2, )))))))
or like this:
=INDEX(IFERROR(1/(1/(IFNA(VLOOKUP(I4:I&"×"&J4:J,
{Advertising!B3:B&"×"&Advertising!C3:C, Advertising!AE3:AK},
MATCH(IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )), Advertising!AD1:AK1, 0), ))/
COUNTIFS(I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )),
I4:I&"×"&J4:J&IFNA(VLOOKUP(G4:G, Sheet3!A:B, 2, )))))))
Use match(), like this:
=arrayformula(
iferror(
vlookup(
I4:I & J4:J,
{ Advertising!B3:B & Advertising!C3:C, Advertising!B3:AK },
match(G4:G, Advertising!A1:AK1, 0),
false
)
)
)
See the new Solution sheet in your sample spreadsheet. The formula is in cell P4.
Note that not all the country names in your search keys are present in the data.
Im seeking some experienced advice, as I have been working on a little project to automate how we gather data in my office using Google Sheets(Please note that I can't use add-ons).
I'm encountering difficulties in finding a way to merge columns that have the same name, but without deleting/merging the row(because im pulling stats for the different tasks employees handle).
In the example you can see that column A has names that repeat because each individual completes one or more tasks, so my goal would be to find a way to automatically merge the repeating names in column A without affecting the rest of the columns.
I believe it is important to know that the table auto-populates as im currently using a filter function, because I paste all my data in the excel and it filters only my agents names.
Here is the formula that im using in c26:
=FILTER(A3:G22,ARRAYFORMULA(ISNUMBER(MATCH(A3:A22,{"Mary";"Jason";"Ana";"Jen";"Ben";"Helen";"Dan";"Richard";"Breg"},0))))
Please tell me that there is a way to do this!
Here is a link to the example Doc That I made
https://docs.google.com/spreadsheets/d/1RsCeHfzzbRsUDnj6UmmCdfzjryp-2xW09UTCx_qfIpA/edit?usp=sharing
Here you can do it, but can't merge by formula:
= ARRAYFORMULA (
ifna (
vlookup (
ifna (
sort (
{ row(A4:A22) *
len ( vlookup ( A4:A22,
{"Ana";"Jen";"Ben";"Helen";"Dan";"Richard";"Breg"},1,0)
)^0}
,1,true
),""
)
, { row(A4:A22),
left(A4:A22, 1000 *
transpose (
split (join("","1," & rept("0,",countif(A4:A22,unique(A4:A22))-1)),",",true,true))
),
B4:G22
},{2,3,4,5,6,7,8},false
),""
)
)
Another formula with the same result:
= ARRAYFORMULA (
ifna(vlookup (
sort (
{ row(A4:A22) *
len ( vlookup ( A4:A22,
{"Ana";"Jen";"Ben";"Helen";"Dan";"Richard";"Breg"},1,0)
)^0}
,1,true
),
{ row(A4:A22),
if(transpose(split(join(
"","1," & rept("0,",COUNTIF(A4:A22,unique(A4:A22))-1)),",",true,true))=1,
A4:A22,""
),B4:G22
},{2,3,4,5,6,7,8},false),""
)
)
After a little bit of discussion on the sheet, this query() will display only one name per agent, but still list all the rows for that agent.
=ARRAYFORMULA(ARRAY_CONSTRAIN(QUERY({Sheet1!A1:G22,IF(COUNTIFS(Sheet1!A1:A22,Sheet1!A1:A22,ROW(Sheet1!A1:A22),"<="&ROW(Sheet1!A1:A22))>1,"",Sheet1!A1:A22)},"select Col8,Col2,Col3,Col4,Col5,Col6,Col7,Col1 where Col1 matches '"&TEXTJOIN("|",TRUE,A2:A)&"' order by Col1 label Col8'Name'",3),9^99,7))