IF function in Google Sheets - if-statement

I need a function in a cell to say:
Blank if Tab 1 A2 cell is blank and Tab 2 A2 is blank.
If Tab 1 A2 isn't blank and Tab 2 is blank the cell says "Pending" and if Tab 1 A2 isn't blank and Tab 2 A2 isn't blank then the cell = Tab 2 A2.
I'm working on a Google Sheets that need to reference other cells across 2 tabs.
Here's the function I have at the moment:
=IF(A13<>""&'Import Processing'!A13<>"",'Import Processing'!A13,IF(A13<>"","Pending"))"))
At the moment it's just showing whatever is in Tab 2 A2, and not regarding if Tab 1 A2 is blank or not.

As per my comment, you are looking for the AND logical operator. Instead of & you could use it like so:
=IF(AND(A2="",Sheet2!A2=""),"",IF(Sheet2!A2="","Pending",Sheet2!A2))
Note: You forgot to mention what happens when A2 is empty but Sheet2!A2 has a value. I took it that it A) wouldn't occur, and B) if it does occur, takes value from Sheet2!A2.

try like this:
=IF(('sheet1'!A2= "")*('sheet2'!A2= ""),,
IF(('sheet1'!A2<>"")*('sheet2'!A2= ""), "Pending",
IF(('sheet1'!A2<>"")*('sheet2'!A2<>""), 'sheet2'!A2, )))

Related

Google Sheets: Joining Two Filters to overwrite selection into 1 Dashboard view

I'm trying to build a workout tracker like shown here
Here is a copy of what I have with dummy data.
Current Attempt/what I've tried/want/notes:
I'd like to have one dashboard (Sheet: Dashboard!) instead of two, where both cells B2 or C2 could be drop downs and I'd like to have it so that the most recent selection takes precedence over the other rules. Currently I've managed to merge the filters with some clunky stepwise IF/THEN, but the final false value supersedes the others, instead of resetting the view.
=IF(
AND(B2="",C2=""), //CONDITION
FILTER(D1S!A1:AA,D1S!B:B=max(D1S!B$5:B1006)), //TRUE VALUE/VIEW
//Maybe OR() around entire FALSE VALUE?
IF( //FALSE VALUE/VIEW
B2 <>"", //CONDITION
FILTER(D1S!A1:AA,D1S!B:B=B2) //TRUE VALUE/VIEW
//AND Change C2 to string 'Exercise' //DESIRED
If( //FALSE VALUE/VIEW
C2<>"", //CONDITION
sort(filter(D1S!A:AA,D1S!C:C=C2),2,FALSE) //TRUE VALUE/VIEW
//AND Change B2 to string "Date" //DESIRED
As a result, I don't think conditionals are the way to go here- instead I think Filter may be better. I just don't know the simplest way to do so for both.
Desired outcome:
Essentially, If both B2 and C2 are blank, get the most recent date workout filter view, If either is filled, then get that view which was most recently selected and make the other cell "blank"/ altered to a header string (eg "date" or "exercise").
EG:
When you open the dashboard- nothing is filled so you get the most recent data.
Then if you select a date in B2, from the drop down you get that filter (ignoring/making C2 say "exercise". Then, with this view, if you select an exercise, it will 1- blank out the value in B2 and say "date" and then 2 the view will just be the filtered view of the exercises.
I hope I explained that clearly. Please let me know if any further clarifications are needed!
add one row above then paste this into B1:
={""; ""; "Date"}
next, paste this into C1:
={""; ""; "Exercise"}
now you can hide row 1 and perhaps change color to reddish and paste this into A3:
=ARRAYFORMULA(QUERY({IF(ISBLANK(D1S!A3:A), D1S!A3:A, ), D1S!B3:AA},
"where 9=9 "&
IF(B3="Date",," and Col2 = date '"&TEXT(B3, "yyyy-mm-dd")&"'")&
IF(C3="Exercise",," and Col3 = '"&C3&"'")))
demo sheet

How to copy cells to new location while removing blanks?

I am looking for a formula that reads one row of 5 cells, and fills the new row with the contents of the original row, but with the non-numeric cells removed and the rest shifted to the left:
Original
*P* *Q* *R* *S* *T*
*23* 8 3 2
(Note: The "blank" cells aren't actually blank, the only way I can get them to read correctly in a formula is if I reference them as "". I am guessing this is because P23:T23 are also references to other cells, instead of direct numbers.)
Result
*B* *C* *D* *E* *F*
*3* 8 3 2
I am looking for the formula to be executed in cell B3. I thought this would work:
=FILTER(P23:T23,NOT(ISBLANK(P23:T23)))
but, it didn't get rid of the blank cells, probably because Google Sheets doesn't think P23 & S23 are blank. Any ideas?
Edit: Here's a link to the sheet: https://docs.google.com/spreadsheets/d/14M6XggpIUXNdZ5ihQ7ipim44wsn4u-ywMZCG4kYMlQY/edit?usp=sharing
try:
=INDEX(SPLIT(JOIN(",", IF(ISNUMBER(P23:T23*1), P23:T23, )), ","))
or:
=FILTER(P23:T23, ISNUMBER(P23:T23))

How to countif 56 exists in 156/56/2567 and only return true once? Google sheets

I have one sheet with data on my facebook ads. I have another sheet with data on the products in my store. I'm having trouble with some countifs where I'm counting how many times my product ID exists in a row where multiple numbers are. They are formatted like this: /2032/2034/2040/1/
It's easy on the rows where only one product ID exists but some rows have multiple ID's separated by a /. And I need to see if the ID exists as a exact match alone or somewhere between the /'s.
Rows with facebook ads data:
A1: /2032/2034/2040/1/
A2: /1548/84/2154/2001/
A3: /2032/1689/1840/2548/
Row with product data:
B1: 2034
C1: I need a countifs here that checks how many times B1 exists in column A. Lets say I have thousands of rows with different variations of A1 where B1 could standalone. How do I count this? I always need exact matches.
You can compare the number you want (56) with the REGEX #MonkeyZeus commented whith a little change -> "(?:^|/)"&B1&"(?:/|$)" so the end result is:
=IF(REGEXMATCH(A1, "(?:^|/)"&B1&"(?:/|$)"), true, false)
Example:
UPDATE
If you need to count the total of 56 in X rows you can change the "True / False" of the condition for "1 / 0" and then do a =SUM(C1:C5) on the last row:
=IF(REGEXMATCH(A1, "(?:^|/)"&B1&"(?:/|$)"), 1, 0)
UPDATE 2
Thanks for contributing. Unfortunately I'm not able to do it this way
since I have loads of data to do this on. Is there a way to do it with
a countif in a single cell without adding a extra step with "sum"?
In that case you can do:
=COUNTA(FILTER(A:A, REGEXMATCH(A:A, "(?:^|/)"&B2&"(?:/|$)")))
Example:
UPDATE 3
With the following condition you check every single possibility just by adding another COUNTIF:
=COUNTIF(A:A,B1) + COUNTIF(A:A, "*/"&B1) + COUNTIF(A:A, B1&"/*") + COUNTIF(A:A, "*/"&B1&"/*")
Hope this helps!
try:
=COUNTIF(SPLIT(A1, "/"), B1)
UPDATE:
=ARRAYFORMULA(IF(A2<>"", {
SUM(IF((REGEXMATCH(""&DATA!C:C, ""&A2))*(DATA!B:B="carousel"), 1, )),
SUM(IF((REGEXMATCH(""&DATA!C:C, ""&A2))*(DATA!B:B="imagepost"), 1, ))}, ))

How to input "P1" into C if H returns text? google sheets

how would I auto-input text "P1" or "P2" or "P3" (priority 1,2,3) into column C if column B returns a certain condition from a list.
example: if Cell H1 = AD01A01, the script will find what priority list its in and change cell C1 to return the prioity.
The script or formula needs to be able to identify if cell A1 is a lower prioriry and chnage it to higher priority if the condtion is met (even if cell A1 was manualy edited)
Also i need to be able to keep the data validation drop down in place so cell A1 can changed manualy without removing any formula (if used)
Auto Priority
try:
=IF((B1<>"")*(B1="certain text"), "P1", )
with extended certain text:
=IF((B1<>"")*(B1="certain text 1")*(B1="certain text 2"), "P1", )
or if you got more values:
=IF((B1<>"")*(REGEXMATCH(B1, "text1|text2|text3"), "P1", )
and then if you want arrayformula, jyst wrap it into it and extend ranges...

Adding to cell value based on last non-empty cell in column in Google Sheets

In a column with periodic values (e.g., A1 = "1.1", A2 = " ", A3 = "1.2"), I can't find a solution to automate this.
That is, if A1 = "1.1", I want the next cell in that column to be a sequential number. In other words, if I paste whatever formula comes out of this post into A5, where A1 = 1.1 and A2 to A4 = blank, then A5 should = A1+0.1.
If I'm understanding correctly, this formula could be entered in A5:
=MAX(A$1:A4)+0.1
and then that cell could be copied and pasted in other cells in that column, and the range reference should change as required.
Any easy solution non-VBA would be to run 2 separate columns alongside using this formula from B2:
=if(A2="",B1,B1+0.1)
If you then wanted to clean out some of the values from that list run another formula from C2 with:
=if(B2=B1,"",B2)
and then copy and paste this column as values.