We have the following data
Col. B
Col. C
3
noun
spring
4
ver.
spring
5
ver.
spring
We need rows 4 and 5 (both columns B and C) to turn red because they are duplicates
We have tried
=(COUNTIF(B$3:B377,B3)>1)*(COUNTIF(C$3:C377,C3)>1)
=AND((COUNTIF(B$3:B377,B3)>1),(COUNTIF(C$3:C377,C3)>1))
=COUNTIF(B$3:B377&C$3:C377,B3&C3)>1
but cannot make it work.
Using =COUNTIFS(B$3:B377,B3,C$3:C377,C3)>1 works for just column B
Sorry but none of suggested answers or other links worked.
But finally found correct solution.
=COUNTIFS(B$3:$B$377,$B3,C$3:$C$377,$C3)>1
This is the only solution.
Use the correct mix of absolute and relative references in your conditional formatting custom formula rule:
=countifs($B$3:$B$377, $B3, $C$3:$C$377, $C3) > 1
The question does not specify whether columns B and C should be considered tuples or if columns B and C should be considered separately. To handle the latter case, use countif(), like this:
=(countif($B$3:$B$377, $B3) > 1) * (countif($C$3:$C$377, $C3) > 1)
I use a countif like this, this is only taking consideration column B:
=countif($B$2:$B$377, $B2)>1
And it look like this:
To make it work with all the columns, I simply added the columns as individual ranges. Like this:
Update:
For both columns, you can use:
=AND(countif($B$2:$B$377, $B2)>1,countif($C$2:$C$377, $C2)>1)
Related
I want to use arrayformula or filter like with the result of a list of numbers. My question is how to place at the bottom a total of the preceding numbers. The challenge is this is dynamically sized. So when I try to include an option to sum the numbers it doesn't work.
What complicates this even further I would then want to include some numbers below this that aren't included in the sum.
What I tried was this:
={"title"; ArrayFormula; sum of previous cells}
Projects
Title
P1
1
P2
2
P3
1
P4
2
Total
6
Edit: An example that I've used that didn't work out is this:
={arrayformula(if(filter($A2:$A,$A2:A<>"",$A2:$A<>"Total Sum",$A2:$A<>"(to be hired)")="","",{countifs('org 1'!$F$2:$F$1000),"="&filter($A2:$A,$A2:$A<>""),'org 1'!$A$2:$A$1000"),"<>(to be hired)")}));"Total hired"}
Edit:
Here's an example link:
https://docs.google.com/spreadsheets/d/1iBkX1B53vYQVUJ6j8dNOE_ck1dONidsqyNuO0lgSKHw/edit?usp=sharing
I'm using multiple tabs as a reflection to what I'm working with. The tab everything's suppose to show is the Indirect example tab.
I'm using the Source tab as a reference for the tabs I'm targeting. The data tabs is the place I'm drawing the info from.
I'm thinking that I won't be able to do this with ArrayFormula. Probably with Query instead. Not sure what it would look like. If ArrayFormula won't work then a query example would be nice.
see:
={"title"; FILTER(A:A, A:A<>""); SUM(A:A)}
={QUERY({A1:B}, "where Col1 is not null label Col2'title'"); "Total:", SUM(B:B)}
I'd like to run a =SUM(A1:G1), but always skip one column, regardless if it has value or not.
In this case, it should calculate A1+C1+E1+G1.
Is there another function I could append to SUM() or other similar functions as SUM in order to skip one column?
Thank you!
Using the following method you can calculate any number of alternate columns, without the need of manual +
Suppose your data is in second row onwards, use this formula
=SUMPRODUCT(A2:G2, MOD(COLUMN(A2:G2),2))
Simply a sumproduct of cell values and a array of {1,0,1,0,1...}
Another slight variation
=SUMPRODUCT(A2:G2*ISODD(COLUMN(A2:G2)))
But if the even columns contain letters instead of numbers this will give an error, so you can use instead
=SUMPRODUCT(N(+A1:G1)*ISODD(COLUMN(A1:G1)))
Comparing #AnilGoyal's answer, this works as well
=SUMPRODUCT(A1:G1,--ISODD(COLUMN(A1:G1)))
You can use:
=SUM(INDEX(A1:G1,N(IF(1,{1,3,5,7}))))
Or with Excel O365:
=SUM(INDEX(A1:G1,{1,3,5,7}))
A bit more of a general solution:
=SUMPRODUCT(MOD(COLUMN(A1:G1),2)*A1:G1)
Or with Excel O365:
=SUM(MOD(COLUMN(A1:G1),2)*A1:G1)
Or even:
=SUM(INDEX(1:1,SEQUENCE(4,,1,2)))
Since you included Google-Sheets, I'll throw in an option using QUERY():
=SUM(QUERY(TRANSPOSE(1:1),"Select * skipping 2"))
Maybe a bit more verbose, but very understandable IMO.
Consider something of the format:
=SUM(A1:G1)-INDEX(A1:G1,2)
The 2 in the formula means remove the 2nd item in the part of the row. (so the 999 is dropped)
So the formula =SUM(BZ10:ZZ10)-INDEX(BZ10:ZZ10,2) drops CA10 from the sum, etc.(a similar formula can be constructed for columns)
google sheets:
=INDEX(MMULT(N(A1:H3), 1*ISODD(SEQUENCE(COLUMNS(A:H)))))
=INDEX(IF(ISODD(COLUMN(A:H)), TRANSPOSE(MMULT(TRANSPOSE(
IFERROR(A1:H3*ISODD(COLUMN(A:H)), 0)), 1^ROW(A1:A3))), ))
I'm looking for a way to add together a dynamically generated list of ranges using (I'm guessing) an ARRAYFORMULA.
The normal way of attacking this is fine if there is a known list of ranges, the example of the results I want would work using this:
=ARRAYFORMULA( A1:A10 + B1:B10 )
In the case I'm after I want to add together ranges in multiple sheets. I don't want the users to have to manually adjust the array formula every time they add a new sheet to be calculated, and I also want to be able to add some logic to include or remove the particular sheet from the calculation, but for now I'm happy to ignore that and just focus on adding cells together.
My approach to this was to create a column with a list of names, each one matching a sheet in the document, and then using that list to dynamically build the list of ranges to add together, using INDIRECT.
.------------.
| sheet1 | <---- SheetListNamedRange
|------------|
| sheet2 |
`------------'
Here's a quick example
=ARRAYFORMULA( INDIRECT("'" & SheetListNamedRange & "'!D4:75") )
There are lots of failure modes depending on how it's done, but this particular formula only puts in the values of the first sheet and ignores any others, which I guess makes sense.
What I'm after is kind of the equivalent of i++ in a loop found in a normal coding language. Is there some way of making this work?
If I understand you correctly, you'd like to get a list generated based on different ranges across different sheets. If your case is as simple as the one you mention in the beginning of your post, the following would do the job.
={Sheet1!A1:A2; Sheet2!B1:B2}
If you want the sum of all these values, you can use SUM.
=SUM({Sheet1!A1:A2; Sheet2!B1:B2})
Please let me know if this isn't what you were looking for, so I can change the answer accordingly.
you can't refer to array of arrays in INDIRECT. you will need to INDIRECT each sheet which contains array.
=SUMPRODUCT(ARRAYFORMULA(INDIRECT(A1&"!"&"D:D")+
INDIRECT(A2&"!"&"D:D")+
INDIRECT(A3&"!"&"D:D")+
INDIRECT(A4&"!"&"D:D")))
note1: in this case result is 25 as sum of 10 + 15.
10 is sum of sheet1!D:D
and 15 is sum of sheet2!D:D
note2: there is no sheet3 and sheet4 which is equal to 0 in INDIRECT
note3: D:D of the sheet where you have the list of sheets needs to be empty
I have a Google Sheet where I have several columns of data, and I want to get a count of how many rows match two criteria, where one of the criteria is matching either one of two values.
Here’s an example of the data I have:
What I want to do is things like: get a count of how many rows have “Yes” in column A, and either “A” or “C” in column B. Or how many rows are “No” and either “I” or “X”.
I’ve come up with this:
=COUNTIFS($A1:$A21,"Yes",B1:B21,"="&"A")+COUNTIFS($A1:$A21,"Yes",B1:B21,"="&"C")
…but that feels clunky, and makes it harder to update if I decide to shift columns around. Not to mention really bad if I want to combine multiple bits of information into a single cell, such as this:
=(COUNTIFS($A1:$A21,"Yes",B1:B21,"="&"A")+COUNTIFS($A1:$A21,"Yes",B1:B21,"="&"C")) & "/" & (COUNTIFS($A1:$A21,"No",B1:B21,"="&"A")+COUNTIFS($A1:$A21,"No",B1:B21,"="&"C"))
I mean, that’s just awful. It works, but it’s awful.
I’ve tried using OR() without success, and also tried curly-bracket syntax without success. I fully acknowledge I may have done both of them wrong, but if so, darned if I can figure out what I missed. Any Sheets mavens willing to take pity on an old dude and show me a much smarter way to do this?
Shortest one so far:
=SUMPRODUCT(REGEXMATCH(A1:A8&B1:B8,"(?i)Yes(A|C)"))
CONCATENATE both columns using & and use REGEX on the result.
(?i) Case insensitive
yes(A|C) yes followed by A or C
SUM up all the trues.
For a complex condition,
=ARRAYFORMULA(SUM(--REGEXMATCH(A1:A8&B1:B8,"(?i)yes(A|C)"))&"/"&SUM(--REGEXMATCH(A1:A8&B1:B8,"(?i)no(I|X)")))
Note that there should be no trailing spaces following yes/No and no leading spaces before A or C etc. If there are, use TRIM.
I would use query with variables. In F1 put:
=query(A:B,"select count(A) where A ='"&C2&"' AND B='"&D2&"' OR A ='"&C2&"' AND B='"&E2&"'")
In C2 enter "Yes" or "No" and in D2 and E2 enter the B letters (or leave blank). Enter whatever headers you want in C1, D1, and E1.
I'm not sure if this is exactly what you're looking for, but you could simplify it a bit by just creating a "pairings" list.
E2: =COUNTIFS(A:A,$C2,B:B,$D2)
E3: =COUNTIFS(A:A,$C3,B:B,$D3)
...
E6: =SUM(E2:E5)
The benefit is that it's flexible - you can add as many pairings as you want later on. Also, no complexity of array formulas.
For complex logic, use more powerful commands like query or filter.
count the rows with “Yes” in column A, and either “A” or “C” in column B.
becomes
=query(A:C, "select count(A) where A='Yes' and (B='A' or B='C')")
or
=query(A:C, "select count(A) where A='Yes' and (B='A' or B='C') label count(A) ''")
if you don't want to have a column header such as "count".
This is pretty much stating the goal in English (well, SQL version of it).
Simplify:
Create a column C that is TRUE if B is A or C, FALSE otherwise.
Create a column D that is TRUE if B is I or X, FALSE otherwise.
Create a column E that is TRUE if A is "yes" and C is TRUE.
Create a column F that is TRUE if A is "no" and D is TRUE
Create a column G that is column E or column F.
Sum up the values in column G.
I have raw data in my spreadsheet that comes from a Google Form that looks like the following:
(Cost) (Source) (Frivolous) (Medium) (Comments)
A B C D E
1 15.94 McDonalds Yes Credit was hungry
2 98.32 School No Check Paid for textbooks
3 843.00 Hospital No Check Surgery
4 0 asdff Yes N/A Ignore this one woops
5
6 23.99 Dentist No Credit Check up
I want this data to always be copied to a different sheet, but ONLY the data that matches a condition. That condition in this case is if Frivolous is No, meaning I only want on this separate page to track valid important spending.
My second page I want them to look like the following:
(Cost) (Source) (Frivolous) (Medium) (Comments)
A B C D E
1 98.32 School No Check Paid for textbooks
2 843.00 Hospital No Check Surgery
3 23.99 Dentist No Credit Check up
Notice how empty entries are ignored and also entries with Yes under Frivolous are ignored as well.
How would I achieve this? I have absolutely no idea how that would work since I've only been able to achieve this through filter which will not work for this.
I would like to say a few words in defense of Google Spreadsheets and show some great functions that will work, but they are not supported by [excel].
Query
First you may use simple query:
=QUERY(sheet1!A:E,"select * where C = 'No'")
This single short formula will give the desired result, there's no need to fill right and down.
Filter
Actually you may use filter too. This function seems to work too:
=FILTER(sheet1!A:E,sheet1!C:C="No")
Please, read more info about this functions:
Filter
Query and full Query Language Reference
You'll find many exciting things that could be done in Google spreadsheets.
Actually, I was having some trouble with [google-sheets] ArrayFormula function so I used an old-school formula with SMALL and INDEX function in its array form. In A2,
=iferror(index(Sheet13!A$1:A$99, small(index(row($1:$99)+(Sheet13!$C$1:$C$99<>"no")*1E+99, 0, 0), row(1:1))), "")
Fill both right and down.
So you were in fact correct that this could be solved in [excel] with an identical solution as [google-spreadsheet]. However, there are superior methods in newer [exce] (2010+) using the AGGREGATE function that [google-spreadsheet] does not support and I'm sure that [google-sheets] has more elegant functions that I am not recalling right this moment.
Look to Sheet13 and Sheet14 here for the working sample.