So i have this Formula, and it works great, it finds, and counts instances where a name appears, with a given text from AD:AD in the previous column that has Square brackets.
=IFERROR(INDEX(QUERY({regexreplace('All Report Sheet'!$B$1:$B, "\[|\]",),'All Report Sheet'!$C$1:$C},"select count(Col1) where (Col1 matches '"&JOIN("|",REGEXREPLACE($AD$2:$AD, "\[|\]",))&"') and Col2='"&$A14&"' label count(Col1) ''")))
I have recently seen that it is not counting names with regular brackets so i tried to tweek it to allow that to the Below formula, but i'm having no luck at all, i'm not sure of the issue.
=IFERROR(INDEX(QUERY({regexreplace('All Report Sheet'!$B$1:$B, "\[\]\(\)",),'All Report Sheet'!$C$1:$C},"select count(Col1) where (Col1 matches '"&JOIN("|",REGEXREPLACE($AD$2:$AD, "\[\]\(\)",))&"') and Col2='"&$A65&"' label count(Col1) ''")))
Any Help is appreciated
Related
I'm looking for an efficient way to gather and aggregate some date in Google Sheets. I've been looking at the query function, pivot tables, and Index + Match formulas, but so far I've not found a way that brings me to the result I'm looking for. I have a set of data which looks more or less as follows.
The fields with an X represent irrelevant data which I don't want to show up in my end result. They only serve to illustrate that there are columns of data that I don't want in between the columns of data that I do want. The data in those columns is of varying types and of varying values per type, they are not actually fields with an "X" in it. Only the fields with numbers are of interest along with the related names at the top and left of those. The intent is to create a list that looks more or less like this.
I've highlighted those yellow fields because that data has been aggregated. For example, in the original file field D3 shows a relation between Laura and Pete with the number 1, and field L3 also shows a relation between Laura and Pete, so the number in that field is to be added to the number in the other field resulting in an aggregated total of 2 for that particular combination.
I would really appreciate any suggestions that can help me get to an elegant and efficient solution for this. The only solutions I can come up with would involve multiple "in-between" sheets and there just has to be a better way.
UPDATE:
Solved by applying the solution in player0's answer. I just had to switch around the order of Col1 and Col2 in the formula to get the table sorted the way I needed it. Formula looks like below now. Many thanks to both player0 and Erik Tyler for their efforts.
=INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&D1:N1&"×"&D2:N), "×"),
"select Col2,Col1,sum(Col3)
where Col2 is not null
and Col3 is not null
group by Col2,Col1
label sum(Col3)''", ))
try:
=INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&D1:N1&"×"&D2:N), "×"),
"where Col3 is not null and Col2 is not null", ))
update:
=INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&D1:N1&"×"&D2:N), "×"),
"select Col1,Col2,sum(Col3)
where Col3 is not null
and Col2 is not null
group by Col1,Col2
label sum(Col3)''", ))
Given your current data set (which only appears to extend to Col N), place the following somewhere to the right of Col N:
=ArrayFormula(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(SPLIT(QUERY(FLATTEN(FILTER(IF(NOT(ISNUMBER(D2:N)),,D1:N1&"~ "&A2:A&"|"&D2:N),A2:A<>"")),"Select * WHERE Col1 Is Not Null"),"|"),"Select Col1, SUM(Col2) GROUP BY Col1 LABEL SUM(Col2) ''")&"~ "),,2)),"~ ",0,1))
It would be better if this were placed in a different sheet from the original data. Supposing that your original data sheet is named Sheet1, place the following version of the above formula into a new sheet:
=ArrayFormula(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(SPLIT(QUERY(FLATTEN(FILTER(IF(NOT(ISNUMBER(INDIRECT("Sheet1!D2:"&ROWS(Sheet1!A:A)))),,Sheet1!D1:1&"~ "&Sheet1!A2:A&"|"&INDIRECT("Sheet1!D2:"&ROWS(Sheet1!A2:A))),Sheet1!A2:A<>"")),"Select * WHERE Col1 Is Not Null"),"|"),"Select Col1, SUM(Col2) GROUP BY Col1 LABEL SUM(Col2) ''")&"~ "),,2)),"~ ",0,1))
This separate-sheet approach and formula allows for the original data to extend indefinitely past Col N.
I am working on a progress tracker with Google sheets. I have 2 tables as in below screenshot. On the right table, the number of subtasks per each task must be auto-populated based on data from left table.
I'm looking for the expression that would somehow calculate the subtask count with the ensemble below. The approach I'm thinking is to - for every subtask, locate the last non-empty task_id cell so far, which can be used for aggregation.
What I've tried:
The temporary workaround I did is to add task_id for all subtasks and a countif formula for count
=ArrayFormula(if(isblank(D2:D), "", countifs(B2:B, "<>", A2:A, "="&D2:D)))
It works but I don't feel like repeating the task_id for every subtask since its a chore.
Thanks in Advance!
Clear contents of range D:E and try in D1
=query(ArrayFormula(if(isblank(B2:B),,
vlookup(row(A2:A),
filter({row(A2:A),A2:A},len(A2:A)),2))),
"Select Col1, Count(Col1) where Col1 is not null group by Col1 label Col1
'task_id', Count(Col1) 'Subtask count'", 0)
and see if that works?
Thanks for the help. I have a large-ish data set where I am trying to query a long column of 2-3 word phrases.
I am using the following code to try and pick out the frequency of the repeated words. Example data below.
My issue is that the code is not resolving - I think it is because there are some special characters in the data.
Some Japanese, some copy-right signs, URLs, and greek symbols.
1) Is there a way to easily remove rows with special characters?
2) Am I doing something else incorrectly?
3) How would I do the same frequency formula I have here - but with two word phrases and three word phases?
=ArrayFormula(QUERY(TRANSPOSE(SPLIT(JOIN(" ";B3:B);" ")& .
{"";""});"select Col1, count(Col2) group by Col1 order by count(Col2)
desc limit 10 label Col1 'Word', count(Col2) 'Frequency'";0))
I received the code from here, btw.
Google Docs spreadsheet formula for most frequent keywords
Besides the extra "." the formula seems to refer to the wrong column. Try this:
=ArrayFormula(QUERY(TRANSPOSE(SPLIT(JOIN(" ",A:A)," ")&{"";""}),"select Col1, count(Col2) group by Col1 order by count(Col2) desc label Col1 'Word', count(Col2) 'Frequency'",0))
This also counts all, not just the top 10.
I don't think this approach will work for two word phrases.
For the moment I find myself with a problem in my formula. I have a huge list of numbers in my column A, where I want to know the number that occurs most often (using the mode function). To do so, I also had to exclude 0 as a number.
=ARRAYFORMULA(mode(ifs(A2:A50<>0;A2:A50)))
However, I want to know which number occurs most often after the first number. I tried this formula but did not get results, I continued to get the 41 (which is the number that occurs most times in this list).
=ARRAYFORMULA(mode(ifs(A2:A50<>0;A2:A50;A2:A50<>B2;A2:A50)))
How can I solve it so that I can ask for a 3rd number that occurs more often?
Thank you!
=QUERY(index(if({1,1},A:A)),
"select Col1, Count(Col2) where Col1 is not null group by Col1 order by Count(Col2) desc")
index(if({1,1},A:A) is to double the column.
EDIT.
=QUERY({A:A},
"select Col1, Count(Col1) where Col1 is not null group by Col1 order by Count(Col1) desc")
Is it possible to write a query (inside a formula) that references non-adjacent (discontinuous, discontiguous, I don't know the proper phrase) ranges? For instance: =query(A2:C,E2:F,"Select Col2 where Col5=3")
I want to be able to put my query in Column D, so I wanted to split the range around it. If I just say "Query(A2:F..." it will detect circular dependency when the equation is in Column D.
If it helps, I have shared a spreadsheet with an example (highlighted in yellow):
Try:
=query({A2:C,E2:F},"Select Col2 where Col5=3")
or if you don't want the label use:
=query({A2:C,E2:F},"Select Col2 where Col5=3 label Col2 ''")
#Pawel Szczur
Have you tried your formula with "\"?
=QUERY({s1!F1:F12115\s1!AH1:AH12115}, "SELECT Col1,Col2")