How do I conditionally highlight cells based off data from another sheet? - google-sheets

I have two tabs in a Google Sheets file. One contains data to display (auto-generated), and another contains information about availability. They appear as such, where the sheets correspond 1-to-1:
User tally
A B C D
+----------+------+------+------+
1 | | OS 1 | OS 2 | OS 3 |
+----------+------+------+------+
2 | Device A | 12 | 0 | 512 |
+----------+------+------+------+
3 | Device B | 0 | 156 | 18 |
+----------+------+------+------+
4 | Device C | 0 | 0 | 0 |
+----------+------+------+------+
OS availability
A B C D
+----------+------+------+------+
1 | | OS 1 | OS 2 | OS 3 |
+----------+------+------+------+
2 | Device A | 1 | 0 | 1 |
+----------+------+------+------+
3 | Device B | 0 | 1 | 1 |
+----------+------+------+------+
4 | Device C | 0 | 0 | 1 |
+----------+------+------+------+
As you can see, the Devices for which an OS is not supported all have 0 users, as expected. However, there are some Devices that do support an OS, but 0 users have that combination (i.e. Device B on OS 3, and Device C entirely).
In my User tally spreadsheet, I want to use Conditional Formatting to change the background and text color of unsupported combinations to the same thing, making it appear as if the cell is completely blank. However, I want supported combinations to display their 0, indicating that users can use this combination, but don't for some reason.
I tried placing the following into the Conditional Formatting panel for 'User tally'!B2:D4 as a Custom formula is (hoping B2 would change per-cell like it does when you paste a formula across many cells), but it didn't appear to have an effect:
EQUAL('OS support'!B2, '0')
How do I use Conditional Formatting to change the color of each cell based on counterpart data from another table?

Place the following into the Conditional Formatting panel for 'User tally'!B2:D4 as a Custom formula:
=OFFSET(INDIRECT("'OS support'!A1"),row(B2)-1,COLUMN(B2)-1)=0

Related

How to copy a whole row as a template and replace one columns value in Google Sheets

I have a sheet which im using to build product data. I need to handle some custom SKU's and id like to have them stored in a string like "XYZ,ABC,FGH" in an alternate sheet.
The generic products are generated in the other sheet for various sizes automatically. I would like on the end of this list to be able to take one of these automatic rows as a template and replace the SKU with one of the custom SKU's if they exist in the other config sheet.
So for example:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
Then append:
ABC | X
XYZ | X
FGH | X
Keeping the existing columns the other products use.
The X's are just a representation for the other columns I want to copy (ive added some further columns as example data). The only thing I want to change is the SKU. Its a duplicate apart from the SKU (which I want to replace) and the Quantity. The consistent one to copy and use as the template would be the row with PARENT as the SKU.
The result is to just be a new row underneath M5 row. These are additional rows to just be tagged onto the end except for a change in the SKU.
The import is a lot of duplication to the database which is the product attributes like width, height, depth, weight, etc. This is set in a sheet I made with the name VARS. So I would create a simple field in VARS for 'Custom Additional SKUs' in say VARS!$B$10 with the value 'ABC,XYZ,FGH'. These would then use the same columns as the SKU's in say a sheet called INVENTORY.
The end result would be something like:
SKU'S | Name | Width | Height | Weight | Quantity
--------------------------------------------------
PARENT| X | 10 | 20 | 100 | 0
M1 | X | 10 | 20 | 100 | 1
M2 | X | 10 | 20 | 100 | 2
M3 | X | 10 | 20 | 100 | 3
M4 | X | 10 | 20 | 100 | 4
M5 | X | 10 | 20 | 100 | 5
ABC | X | 10 | 20 | 100 | 0
XYZ | X | 10 | 20 | 100 | 0
FGH | X | 10 | 20 | 100 | 0
Final solution based on feedback to help others.
Based on the great input from pnuts I went with the following in column A underneath:
=sort(transpose(split(VARS!A1,",")),1,TRUE)
In column B:
=IF(ISBLANK(A7),"",QUERY(SKU!A2:F2,"select B,C,D,E,F",0))
Works like a charm!
Maybe try:
=sort(transpose(split(NamedRange1,",")),1,TRUE)
and next to the above something like:
=QUERY(SKU!A:F,"select B,C,D,E,F where A='PARENT'",0)
copied down to suit.

DGET with array constant as criteria parameter with a blank element

If I have the following table:
\ || A | B | C | D | E | F |
_______________________________________
1 || H1 | H2 | H3 | H4 | 10 | 20 |
2 || 10 | AA | .2 | 70 | 70 | 100 |
3 || 10 | BB | .3 | 80 | | |
4 || 20 | CC | .4 | 90 | | 10 |
5 || 20 | DD | .5 | 100 | | CC |
6 || | | | | | |
(*All workings examples are in Google Docs)
This works:
=DGET(A1:D5,"H3",{A1:D1;E1,E3,E4,E2})
RESULT = 0.2
But I'm looking for a way to have a blank element in the constant array I'm using as the criteria without referencing a blank cell. I need the blank elements as otherwise DGET treats them as criteria to be evaluated.
Something like this:
=DGET(A1:D5,"H4",{A1:D1;E1,#BLANK,#BLANK,E2})
Where #BLANK is whatever magic makes google docs treat the element as empty.
I know that I can do:
=DGET(A1:D5,"H3",{A1,D1;E1,E2})
And just limit the number of columns in the criteria, but I'd like to specify the entire header set in the constant and just choose the columns I want specified.
For instance if I wanted something like this:
=DGET(A1:D5,"H3",{A1:D1;F1,F3,F3,F2;F4,F5,F3,F3})
RESULT = 0.5
But as this:
=DGET(A1:D5,"H3",{A1:D1;F1,#BLANK,#BLANK,F2;F4,F5,#BLANK,#BLANK})
In addition to the primary question of how to set an empty element, I'm curious if there is a way to perform a similar lookup in Excel. LOOKUP functions do not appear to support filtering on multiple criteria and the Database functions don't support arrays for defining criteria (only a cell range).
I believe that the #BLANK you're looking for is:
""
And, No. Excel does not support such sophisticated arrays.

Matching cell and returning average of multiple columns

I have a Google Sheets with the following sheets:
Heroes
A | B | C | D | E
-------------------------------------------------------
The Flash | 5 | 10 | 4 | 82
Jesse Quick | 0 | 2 | 5 | 4
Quicksilver | 1 | 3 | 12 | 2
Kid Flash | 10 | 9 | 7 | 17
Calc
A | B
-------------------------------------------------------
The Flash |
Quicksilver |
I want to match column A in Calc and return the average value of column B to E from Heroes.
So based on the date above, I want Calc should look like this:
A | B
-------------------------------------------------------
The Flash | 25,25
Quicksilver | 4,5
I had this function in Calc:
=AVERAGEIF(Heroes!A:A;B2;Heroes!B:B))
changed to:
=AVERAGEIF(Heroes!A:A;B2;Heroes!B:E))
but this only returns 5 for The Flash and 1 for Quicksilver.
You can try this
=AVERAGE(ARRAYFORMULA( VLOOKUP(A5,A12:E13,{2,3,4,5},FALSE)))
Where A12:A13 refers to HEROES
and A5 refers to Cal
https://docs.google.com/spreadsheets/d/1AEbci4BN8SyYcmpfOELGRQC4wpRqPn-dUoZy5GdkTyM/edit?usp=sharing
For the Flash have: =AVERAGE(Heroes!B1:E1)
For Quicksilver have: =AVERAGE(Heroes!B2:E2)
Using this pattern allows you to get the average of all the Cells in the column of the hero you want. Remember you have to specify the cells, right now you are specifying the whole columns of B-E, when you just want the row of each hero.

How do I count merged cells separately in Google Spreadsheets?

I'm using countif(a1:a10, "*") to sum the number of names in a guest list. However, some cells have been merged, e.g. for married couples or families where only one name is supplied.
See below for a concrete example, where (+ x) are merged with the cell above:
| A | B |
1 | Cheah | Teo |
2 | Hadi's Family | Robinson |
3 | (+ wife) | Müller |
4 | (+ son) | Chan |
5 | Ganesan | Yeong |
6 | Chng | (+ wife) |
7 | Tan | Ng |
8 | Williams | (+ husband) |
9 | Brecht | (+ daughter) |
10 | Ahmad | |
In the example above, I would like to obtain 10 in column A and 9 in column B.
I've seen #MaxMakhrov's suggestion of last non-empty row, but haven't been able to get a working solution out of it yet.
Any ideas?
The formula of finding last non-empty row may help:
=MAX(FILTER(ROW(A:A),A:A<>""))
But it will give the wrong result if last cells are merged:
Example:
1 a
2
3 b > merged
4
Last non-emty row is 2 in example above because cells 2,3,4 are merged.

How to add the content of a certain number of rows just below the VLookup output (Google spreadsheet)?

For instance:
________A_____|__B__|__C__|
1 | Mouse | 1 | a |
2 | Keyboard | 2 | e |
3 | Headset | 3 | i |
4 | HDD | 4 | o |
=Arrayformula(VLOOKUP("Mouse",A1:C4,{2,3},FALSE) --would return "1" & "a".
Is there a way to make it return the content of 1 row below as well, that "2" & "e" along with "1" & "a"? i.e., the desired final output should look like :
________C_____|__D__|__E__|
1 | | 1 | a |
2 | | 2 | e |
Thanx!
Try offset:
=OFFSET(A1,MATCH("Mouse",A:A,0)-1,1,2,2)
Offset in Google sheets is an arrayformula, so it can return multiple rows and columns.
Match function gives the number of row with matched name.

Resources