I'm using Google Spreadsheets, and I have information populating the sheet through a Form. The data comes through as a timestamp, text, text separated by commas and number separated by commas (Columns A, B, C and D, respectively). Here's a link to a simplified example sheet I made to show my problem.
What I want to do is have the Week in B listed as many times as there are activities. So In B2, it says "Week 2", and in C2 there is "Running, Skiing", and so I would like "Week 2" to be written twice going down. In C3, there is only one activity, so I would only want "Week 2" to be written once this time. In the "I" column I showed what I would like to happen.
What I can do (Column G) is use a combination of Transpose, Split and Rept functions to list B2 (Week 2), F2 amount of times (twice). However, at an arbitrary distance below, I then want to repeat the same the same thing with B3 and F3, and so on and so on. I think I need to use ArrayFormula function, but I don't exactly understand how to in this scenario.
Hope I explained my problem properly, if any more information is needed I'll provide it, thanks.
Erase D column. Rewrite D column.
G2:
=REPT(B2&", ", F2)
Drag fill down.
This should give your table:
=ARRAYFORMULA(TRANSPOSE(SPLIT(TRANSPOSE(QUERY({G2:G5& ", ",C2:D5 & ","},, 500000)), ", ", 0)))
Related
I am trying to display some data in a specific manner, but have quite some issues with my last formula.
I have created this mock file to share (the original has many more tabs), this is just for this last formula that I need.
The data needs to be displayed only on the FSF [Score] tab as seen in columns I to N. The issue there is with the proper positioning of the displayed data in the rows. In row 4, I should have no data from column H onwards.
To give a proper explanation:
A-D is extracted from Responses with a query if the value in Responses!E || F contains TSF
E is extracted from Traffic Safety (Score)
F, H, P and so one, the ones with the numbers do not need editing
I gets the values from Responses based on multiple conditions
- if the person has FSF filed, search for the corresponding row and grab the correct values from the columns: AV, AW, AX, AY, AZ, BA if the language row has EN or EP, EQ, ER, ES, ET, EU if the value in the language cell is NL
The main issue I see with the formula in cell I2 is the
"where Col1 is not null"
which makes every row fill in one after the other.
Any help and advice is appreciated.
I tried some VLookup combinations as well, but could not figure it out. As you can see in each color block there, I have multiple formulas that I am trying to juggle with.
The closest I got was with this formula, but it put put the data in the exact row it was extracted from, instead of matching the B name.
=arrayformula(query(if(
(Responses!E2:E = "First-shift Feedback (FSF)")*(--NOT(ISNA(MATCH(TO_TEXT(B2:B),TO_TEXT(Responses!C2:C),0)))),
query(Responses!CA2:CF, "select CA, CB, CC", 0),
query(Responses!FU2:FZ, "select FU, FV, FW", 0)
),
"", 0
)
)
Let's say I'm collecting reviews on fruits, people submit a google form about a fruit's name (eg. "apple") and its score. This is on sheet 1. let's say the submissions of the fruit names are on col B.
On sheet 2, i have a column (lets say col A) of all fruits (apple, pear, etc)
I would like to add a column on sheet 2 (lets say col B) that asks if there is a review for that fruit. How do I do that?
Goal: select cell from col A (list of all fruits) -> search within col B on sheet 1 to see if someone submitted a review of that fruit -> if text matches, return "Y" and if it does not exist/otherwise, return "N"
Sorry if this sounds super complicated!
I tried using vlookup but i think the "range" part stumped me. also tried if and search but not sure ;-; I don't want to have to input the fruit's name manually every time. I think i'm also having trouble as it's on two different sheets (not two completely different Google Sheets, but two sheets within one Sheet. if that makes sense)
To get a true/false answer, use this formula in row 2 of a free column in Sheet2:
=arrayformula( if( len(A2:A), not(iserror(match(A2:A, 'Form Responses 1'!B2:B, 0))), iferror(1/0) ) )
But it would probably be simpler to just list all fruit and count them:
=query('Form Responses 1'!A1:C, "select B, count(B) where B is not null group by B", 1)
Struggling to get this to work as I need. Basically a set of nested IF formulas with some conditions (see bottom of post for the rules)
I have 3 columns - J, K and L
Column J
contains the last login date (represented by 01/01/1970 if it's never been logged into)
Column K contains the last interaction date (represented by 01/01/1970 if no interaction or blank if within the last 90 days)
Column L contains the last activity date for a different metric. (blank if within the last 90 days)
I have another column, M - which I am intending to use as the calculated field.
This is what I am trying to achieve:
J
K
L
M
01/01/1970
01/01/1970
Recent Activity
26/06/2021
26/06/2021
01/01/1970
01/02/2021
Recent Activity
30/06/2021
01/01/1970
23/03/2020
30/06/2021
So the rules are as follows:
If Col J contains 01/01/1970 OR Col J date is before 25/03/2021 then check Col K.
If Col K contains 01/01/1970 then check Col L. If Col K IS BLANK then show "Recent Activity"
If Col L IS NOT BLANK then show Col L Date. If Col L IS BLANK then show "Recent Activity"
If Cols J, K and L all contain a date, get the most recent date from them
I have pulled out a few tufts of hair trying to get this to work, so any help would be greatly appreciated!
Looking at your rules, is 25/03/2021 a static date or should it be derived from a value somewhere? If static, then try this for the IF statements:
=arrayformula(if(J1:J<>"",if(isblank(J1:J)+isblank(K1:K)+isblank(L1:L)=0,if(K1:K>J1:J,if(L1:L>K1:K,L1:L,K1:K),if(L1:L>J1:J,L1:L,J1:J)),if(J1:J<datevalue("2021-03-25"),if(K1:K=datevalue("1970-01-01"),if(L1:L<>"",L1:L,"Recent Activity"),"Recent Activity"),J1:J)),))
There might be better functions, but this is mainly done with IF().
if(J1:J<>"" will run the subsequent formula as long as there are values in col J.
if(isblank(J1:J)+isblank(K1:K)+isblank(L1:L)=0 checks each row to see if there is a date in col J, K and L.
If there is, then this gets the largest date (it's a bit clumsy but someone else might be able to help):
if(K1:K>J1:J,if(L1:L>K1:K,L1:L,K1:K),if(L1:L>J1:J,L1:L,J1:J))
An alternative to finding the largest date on each row could be:
transpose(dmax(transpose(J:L),{sequence(1,max(if(J:L<>"",row(J:J))))},{J:L}))
or:
query(transpose(query(transpose(J1:L),"select "®exreplace(join("","Max(Col"&sequence(max(if(J:L<>"",row(J:J))))&"),"),",$",)&" ",0)),"select Col2",0)
The other IFs test out the other scenarios.
based on your rules try in row 1:
=INDEX(IF(ISDATE_STRICT(I:I)*ISDATE_STRICT(J:J)*ISDATE_STRICT(K:K),
VLOOKUP(ROW(I:I), SPLIT(SORT(FLATTEN(ROW(I:I)&" "&I:J), 1, ), " "), 2, ),
IF(LEN(I:I&J:J&K:K), IF(I:I<"25/03/2021"*1, IF(J:J="01/01/1970"*1,
IF(((I:I="01/01/1970"*1)+(I:I<"25/03/2021"*1))*(J:J="01/01/1970"*1),
"Recent Activity", ), "Recent Activity"), I:I), )))
I think doing this as an arrayformula is unnecessarily complicated.
Here is a sample sheet made specifically for this question. In it, i placed this formula in cell M2 on a tab called MK.Idea and dragged it down:
=IF(J2,IF(J2>1*"25/3/21",J2,IFERROR(1/(1/MIN(N(K2),N(L2))),"Recent Activity")),)
Does it give the expected results? maybe you could add some more sample data on the sheet and test it out?
I'm looking for a specific Google Sheets formula. I believe it's using COUNTIFS & SUMIF, but I can't work out how to do it, any help would be really appreciated.
So, my "C" column has a number of letter combinations in each cell... These are "FHG" "CS" "MO" and afew others. They are a reference to specific market trading strategies and I'm using this sheet to track every trade I make. So C3 may contain "FHG" C4, "MO" C5, "FHG", C6 "FHG" etc.
In the "I" column, there is a 'profit and loss' column which states how much was generated/lost for that particular row... These are formatted to currency.
At the top of my sheet, I have a summary list of each set of letters and I'm using a COUNTIF statement to work out the total number (instance count) of each particular letter combo and from there, I can work out strike rates, percentages etc.
The thing I can't work out is, 'is there a way to count/sum the relative numbers in the "I" column based on a specific letter combo?' For example, let's say running down today's trades, FHG appears on C3, C6, C8, C12, C16 etc. can I collect and sum the numbers (to create a total) from the corresponding P&L column, I3, I6, I8, I12, I16 etc?
My main aim is to have the following at the top in my "Summary Section":
'Letter Combo/Name Of Trading Technique' - 'Number Of Trades' (Using COUNTIFS down C Column) - 'Total % Win Rate' (Number Of Winners/Number Of Total Trades For Said Strategy - This is done using a separate column of Y or N for winners or losers) - The one that I need help with is - "Total Sum Of Money Generated For Each Particular Letter Combo (Trading Strategy)"...... I've worked out how to do the first 3 columns, but I can't work out how to pick the numbers out from the P&L column (I) based on what kind of trade (letter combo) exists in the corresponding (C) column.
If every trade made the same about of money, this would probably be an easy calculation, but because each return is different, this is proving challenging.
Thanks for any insights :)
try:
=QUERY(A:I; "select C,sum(I) where A is not null group by C label sum(I)''")
or just for SB:
=QUERY(A:I; "select C,sum(I) where C = 'SB' group by C label sum(I)''")
if you want a count too:
=QUERY(A:I; "select C,count(C),sum(I) where A is not null group by C")
So I've Two lists in Google sheets. one is a (relatively short) list of names, let's say a rooster of employees. The second list is (rather a long) list of shifts, which notes the employees who were present.
for example:
List A - (rooster):
___________________
Mike
Linda
Carrie
Dave
List B - (Import_shift_data):
____________________________
Mike, John
Dave, Linda, Mike
Carrie
Dave, John
Linda
Mike
Dave, Carrie, John, Mike
My goal is to count the presence of each employee.
Now, here are the tricky parts:
List B updates every day, and each cell contains more than one name.
List A also updates, as some employees join the team and other leave.
Each shift could by a day shift, or a night shift (listed in another column next to List B) and I need to count them separately.
The Day/night column is in a parallel column next to shift column, and has one of two values, "Day" or "Night"
So my notion was to create an array formula, who can expand or shrink based on the number of values in List A. The problems is, I Can't yield and results from using the whole {list A} as the first argument in the SEARCH function.
I've tried the foloowing:
=Arrayformula(IF(INDIRECT("A2"):INDIRECT(CONCATENATE("A",MAX(Arrayformula(IF(isblank($A:$A),"",Row($A:$A)))))) = 0,"",COUNTIFs('Import_shift_data'!$P:$P,INDIRECT("A2"):INDIRECT(CONCATENATE("A",MAX(Arrayformula(IF(isblank($A:$A),"",Row($A:$A)))))),'Import_shift_data'!$M:$M,"Night")))
.
But this formula only works for a shift with a single employee.
I also wrote this one:
=Countifs(Arrayformula(ISNUMBER(SEARCH(A2,'Import_shift_data'!$P:$P))),"true",'Import_shift_data'!$M:$M,"Night")
which works fine, but I need to manually drag it up or down every time List A (The rooster) is updated.
So my end game is to have two arrays, one that counts night shifts for each employee, and one who counts day shifts. those arrays should automatically shrink or expand by the size of the rooster. (List A)
Note: If relevant, I may also note that the names in {List A} may contain more than one word, in case there are two employees with the same first name.
A copy of the spreadsheet:
https://drive.google.com/open?id=1HRDAy9-T_rflFpzanZq0fmHpV0jTZg6Rc4vHyOu-1HI
day shift:
=ARRAYFORMULA(QUERY(TRIM(TRANSPOSE(SPLIT(TEXTJOIN(", ", 1, B2:B), ","))),
"select Col1,count(Col1) group by Col1 label count(Col1)''", 0))
night shift:
=ARRAYFORMULA(QUERY(TRIM(TRANSPOSE(SPLIT(TEXTJOIN(", ", 1, C2:C), ","))),
"select Col1,count(Col1) group by Col1 label count(Col1)''", 0))
I Think I've found the Solution, I've used player0's idea of rearranging the data vector and split non-single shifts into single cells.
so basically it goes:
=Arrayformula(CountiF(Transpose(SPlit(Textjoin(" , ",TRUE,QUERY('Import_shift_data'!A:P, "select P where M = 'Night' ", 1))," , ",False)),INDIRECT("A2"):INDIRECT(CONCATENATE("A",MAX(Arrayformula(IF(isblank($A:$A),"",Row($A:$A))))))))
Thanks player0 !