Google Sheets: How Do I Colour A Cell Based On Whether Its Number Be Found in Running Column Ranges of Different Tabs - google-sheets

https://docs.google.com/spreadsheets/d/1bLmL6E0odCB4aKBBZWqUeoyEYxKphmInL9wS6lsKQr8/edit?usp=sharing
I'm trying to create a heads up display on the number of Hints a user has collected in a contest.
There are different categories of hints here.
So I'm trying to create a process such that in the respective Category tab (ie AREA / SUBZONE in this case)
Filling in Column B (with the hint number), renders that Hint as being "obtained" and hence showing up "Green" in my Hints Overview sheet.
The problem I'm trying to solve is users are going to collect Hints and classify them by Category. Thus the example hint of BH169 can be present in any of the Category sheets below.
How do you write conditional formatting in Google Sheets to iterate through a given set of ranges for a match of "169" from the Hints Matrix in Dashboard with that of "BH169" in the Hint # column?
I tried pulling some conditional formatting tricks like indirect(), Index(), VLOOKUP. Alot of nested functions within each other but nothing worked out.
Here are some functions I've tried. Now I've entered into a mental block not sure what else I can approach the problem.
INDEX(VLOOKUP(D8, {ROW(INDIRECT("BONUS!B2:B"))-1, INDIRECT("BONUS!B2:B")}, 2, 0))<>""
INDEX(VLOOKUP(D8, {INDIRECT("AREA / SUBZONE!B85:B124")), INDIRECT("SPOT (GENERIC)!B85:B204")}, 1, 0))<>"D8"
INDEX(VLOOKUP(D8, {INDIRECT("AREA / SUBZONE!B85:B124")}, 2, 0))=D8
INDEX( VLOOKUP (D8, { ROW ( INDIRECT(" 'AREA / SUBZONE'!B85:B124") ) }, 2, 0) )<>""
MATCH(D8, {INDIRECT("AREA / SUBZONE!B85:B124")), INDIRECT("SPOT (GENERIC)!B85:B204")}, 1, 0))=D8
The condition formatting is done in Dashboard
Would appreciate some advice and tips. Thank you!

Related

Google Sheets VLOOKUP formula stops working when new item values are added to the column being looked up

Hello stack overflowers.
I have recently been creating a nutrition tracker to better track and control my nutrition. However I have run into an issue. So currently I have a 1 sheet in the nutrition tracker which is a "database" of foods and their macro nutrients per gram. In this sheet, I will enter all the foods that I generally eat and their associated per G nutrients.
this food "database" sheet has the following columns.
FOOD NAME, CALORIES, PROTEIN, CARBS, OF WHICH SUGARS, FAT, OF WHICH SATURATED, FIBER, SALT
This database is then used as a reference, so that when I input each meal as I eat it, I can simply select the food from a drop down list and type the number of G in that meal, and the nutrients will all be calculated for me.
I currently have it setup so that I can select food from the drop down list generated by "foods" sheet, within each meal table I have created. This is then correctly filling in the rest of the columns as expected once I input a weight for each meal. There is however a huge problem.
As soon as the FOOD NAME column of the Foods sheet had values in it below row 7 (not sure why this row is the limit) the whole thing stops working, the data grabs based on VLOOKUP just return 0 and do not act as they are meant to. The strange thing is they work absolutely fine until I enter too many foods (7 foods) into the foods sheet.
Please find below a link to my spreadsheet, maybe you can duplicate it and play around a little yourselves to better understand the issue.
https://docs.google.com/spreadsheets/d/1orwih7s_Z4ew8G1vJcR6qlxyMpX8pqK-3Ynj42qQjcQ/edit?usp=sharing
(if you help me fix it, you will have a free nutrition tracking spreadsheet to help you take control of your diet aswell)
Thanks in advance.
In the June tab, clear all formulas in the range D11:K18.
Then enter in D11
=ArrayFormula(IF(LEN(B11:B18), IFERROR(VLOOKUP(B11:B18, FOODS!A:I, {2, 3, 4, 5, 6, 7}, 0)),))
This single formula will process all values entered in B11:B18.
Note the third parameter of VLOOKUP (set to false). If it is ommitted (as in your formula) it will default to 'true'. That means vlookup expects a 'sorted order' which may not be the case for your data.
References
VLOOKUP
try:
=INDEX(IF(B11:B18="";; IFNA(VLOOKUP(B11:B18; FOODS!A:I; COLUMN(B:G); ))))

Manual data tagging and lookup

I need a system that allows to filters entries by different text tags.
Say we store info about some products. We have Red Apples, Pears, Watermelons, Cucumbers, Peppers and Bread. We store them in sheet named "Data" in column A. Next columns are occupied by tags, like Red Apples are Red, Sweet, Fruit, Unpacked; Peppers are Red, Spicy, Veggie, Packed; Bread is just Packed.
Then on another sheet we have a dedicated range, say A1:A10, which can accept any data tag, like Spicy or Packed. What I need is when somebody enters Spicy and Packed in this range, it looks up all items that are Spicy and Packed and displays them, so in this case it would display Peppers in B1 cell.
To recap: Data!A:A - entry names, Data!B:Z - tags, Main!A1:A10 - tags entered by user, Main!B:B - entries with tags, that correspond to those entered in A1:A10.
I was trying to use FILTER, but I can't figure out how to select proper condition ranges. I feel like this should be possible within this system and I really don't want to delve into scripting field.
This can be achieved using a helper column to collect all the tags and then a =query() formula.
1)
Start by creating a multi-tag column using either =join() or =textjoin(), capturing all the potential tags for each product.
2)
Then use this answer to help you create the =query() formula needed.
There is a pretty simple solution to this.
You would need to add a helper column and count how many tags does your item has from the listed ones, using this formula
=SUM(ARRAYFORMULA(COUNTIF(B1:1,'Main'!$A$1:$A$10)))
Next, in your presentation sheet reserve some place where you can enter tags - one at a time. In my case, it's range A1:A10. Then just paste this formula anywhere else
=IFERROR(FILTER(Data!$B:$B,Data!$A:$A=(10-COUNTBLANK($A$1:$A$10))),"")
At that place, all suitable elements will show up. I also added sorting to the formula, cause why not.
You can use more tags, for that just increase the tag range and edit formula so when there are no tags entered, COUNTIF gives 0.
if Data sheet looks like this:
and you need "constructive" list, you can do:
=SORT(FILTER(Data!A2:A, REGEXMATCH(TRANSPOSE(QUERY(TRANSPOSE(Data!B2:Z),,999^99)),
TEXTJOIN("|", 1, A1:A10))))
spreadsheet demo
if you need a "destructive" list do:
=ARRAYFORMULA(SORT(QUERY({Data!A2:A, TRANSPOSE(QUERY(TRANSPOSE(Data!B2:Z),,999^99))},
"select Col1 where "&TEXTJOIN(" and ", 1, IF(A1:A10<>"",
"Col2 contains '"&A1:A10&"'", ))&"", 0)))

Finding a result based on search query

I'm hoping someone can help with this.
I have two sheets/tabs:
A Database tab that collects links using IMPORTXML.
A spreadsheet that sorts the data.
What I would like to do is automatically categorise certain links from the database tab in certain columns to the sorting tabs.
For example, in column E of the sorting tab is Github. I'd like find the links for Github in the Database tab and sort these appropriately for the matching abbreviation - so I expect and MATCH and INDEX to be involved at some stage as row 1 in the Database tab isn't fixed - the abbreviations header may move.
I am expecting to have a function that searches for "GitHub" in a given search column and returns that cell to the Sorting tab, but I am unable to find a solution for this.
This is an example of the result that I am hoping to achieve, but the screenshot below isn't automated based on data pulled from IMPORTXML, which is the reason for this new spreadsheet.
If anyone can provide help with this, that would be great!
paste in D2 cell and drag to the right:
=ARRAYFORMULA(IF(LEN(INDIRECT("A2:A"&COUNTA($A$1:$A))), IFERROR(VLOOKUP($A$2:$A,
SPLIT(TRANSPOSE(SPLIT(TRIM(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IF(IFERROR(REGEXEXTRACT(
IF(Database!$A$2:$CG<>"", "♠"&Database!$A$1:$CG$1&"♦"&Database!$A$2:$CG, ),
LOWER(D$1)))<>"",
IF(Database!$A$2:$CG<>"", "♠"&Database!$A$1:$CG$1&"♦"&Database!$A$2:$CG, ), ))
,,999^99)),,999^99)), "♠")), "♦"), 2, 0)), ))

Google Sheets, need to edit a column based on two columns on a second sheet

Good morning!
I've been searching high and low for how to do this, and while I feel like I get close I can't get anything more than 'invalid formula' from the conditional formatting in google sheets. So here's what I'm trying to do;
Column C on sheet 1 (Working List) needs to have a red background if the following conditions are met;
Column 'P' on sheet 2 (Complete) has the 'Address Changed' option in the drop down box (its the first one on the drop down, I've been struggling to figure out if it needs to be a '0' given its position in the list or if its 'Address Changed')
Column 'C' on sheet 2 has the same account numbers in Column 'C' on sheet 1.
I can set it up to find duplicate accounts, but I can't seem to figure out how to get the first rule for the drop down box to work. Advice?
Attempts thus far, none of them worked, all were tried separately and not in conjunction with each other. Google just says 'invalid formula' and won't save it or do anything with it.
=and(EQ(Complete!$O, "Address Changed"), EQ('Working List'!$C, Complete!$C))
=match($C2, indirect("Complete!$C:$C"), 0)
=if(EQ, indirect("Complete!$O, "Address Changed""), EQ('Working List'!$C, "Completed!$C"))
=and(indirect("Complete!$O:$O,$O="Address Changed""))
so I've tried to figure out a better way to get it working, and this is what I think might be closer to the answer.
=and(if($O:$O,indirect("Complete!$O:$O),0)),[match($C2,indirect("Complete!$C:$C"),0)]
***Friend helped me solve this. The following worked for what I needed....
=index(indirect("Sheet2!O:O"), match(C1, indirect("Sheet2!C:C"), 0)) = "Address Changed"
Take a look at this sheet with some foo data I built based on your sheet.
https://docs.google.com/spreadsheets/d/1RcM5WX3KWgWq-WWuPgyF-PZe3RP99qWF-IRpSr35Zik/edit?usp=sharing
I used some helper column, as you see.
if sheet2!P1 is changed to "Address Changed" K1 will have value of 1. This is a simple IF function.
if sheet2!C = sheet1!C, L will change to 1. This is another simple ARRAYFORMULA(IF())
Finally, column C will be formatted with the data from K1 and L by this formula
: =AND(L2=1, $K$2=1)
You can then hide the helper column / cell.
If you don't want to use helper column, look at the formula in column D :
=AND(INDIRECT("Sheet2!C2:C") = C2:C, INDIRECT("Sheet2!P1")="Address Changed")
This will serve your purpose.
You cannot refer to another sheet directly in conditional format formula, hence if you don't want to use helper column, you will have to use INDIRECT. This is also the reason why your formula failed in the first place.
I personally wouldn't recommend you to use INDIRECT though...

Using arrayformula to autofill formulas for new entries- comparing cells in the same column

Relative beginner to using formulas in excel/google sheets, and I'm having some trouble figuring out how I can use an array formula to compare cells in different rows but the same column in google sheets (in my case, how I can do =IF(A3=A2,dothis,elsedothis) as an array formula. I'd also be interested if anyone has a different solution other than array formula to autofill formulas in.
The specifics:
I have a list of participants who've done an experiment, and some of them have done it multiple times. With a long list of participants and multiple entries for some participants, it's difficult to see where one participant's info ends and the next begins. So what I want is to alternate the rows in gray and white shading based off of the participant's number (ie. all of 001's entries in gray, all of 002's entries in white, 003's in gray, and so on). To do this, I put in a column on the right using a formula that checks if the participant number in the row above it is the same and, if not, it adds one (I'd like to use this to get a participant count later on). This is what the dataset looks like, and I've included the formula on the right.
A B ... ... X
001 9/1/16 ... ... 1 (1)
001 10/1/16 ... ... 1 (=IF(A3=A2,X2,X2+1))
001 11/1/16 ... ... 1 (=IF(A4=A3,X3,X3+1))
002 9/2/16 ... ... 2 (=IF(A5=A4,X4,X4+1))
002 10/2/16 ... ... 2 (=IF(A6=A5,X5,X5+1))
003 10/5/16 ... ... 3 (=IF(A7=A6,X6,X6+1))
...
All this is working fine and dandy, but the problem is, when I enter a new row, it doesn't automatically fill in the formula, and so the shading doesn't adjust. I suppose I could redrag down the formula every time I enter in new participant info, but that's tedious and I'm not the only one using it, so it's going to get messed up pretty quickly. From what I looked up, arrayformula is what I should be using. But you have to refer to the column as a whole if you use arrayformula. Anyone have any ideas?
Assuming you got the conditional formatting covered, I believe the formula(s) you use can be turned into one single array formula so that the output auto-expands when new rows are added. Example:
={1; ArrayFormula(IF(LEN(A3:A), offset(A2,0,0,ROWS(A3:A),1) + IF(A3:A = offset(A2,0,0,ROWS(A3:A),1), 0, 1),))}
See if that would work for you?
NOTE: the custom formula in conditional formatting used in the spreadsheet is
=AND($X1<>"", ISODD($X1))
One way to achieve the desired result:
To alternate the rows in gray and white shading based on the participant's number do the following:
Under the Format Menu choose conditional formatting
Enteries for the Conditional format rules dialog
In apply to range select the range e.g. A2:A16 (it may include blank cells)
For Format cell if choose Custom formula is
Type =isodd(A2:A16) in the text box below
For Formatting style choose Custom
Choose gray color from the fill button
Finally hit Done
To get a participant count you can use the formula =countunique(A2:A16)
You can do this alltogether without an additional helper column at all, just using conditional formatting:
The custom function to add into the conditional formatting option is this:
=isodd($A:$A)=TRUE
At the end if you still want your participant count, you can use this:
=COUNTA(UNIQUE(A:A))

Resources