IF contains with multiple other conditions - if-statement

this is from a none programmer
I have the formula below that checks 3 conditions
=IF((AND(H2="DWL",K2<=0,W2<>"")), "Send Email", "Wait")
H2= DWL
K2 is Less than 1
W2 is occupied
But I am trying to get so if H2 contains “DWL” plus the other 2 criteria’s are correct
Eg, H2 may contain “DWL1234”, “DWL5678” “DWL25643” or “DWLJHRER”

That will do the trick :
=IF((AND(REGEXMATCH(H2,"DWL"),K2<=0,W2="occupied")), "Send Email", "Wait")
Is this what you need?

Related

Tableau - IF Statement with aggregation

I need to do a aggregation under IF statement in a calculated field
If a city is the same as selected by the user (parameter PAR_SELECT_CITY);
In case the condition 1 is true, then SUM(Number of records) - [PAR_SELECT_QTY]
[PAR_SELECT_QTY] is a parameter that user choose to deduct from the total quantity
In case the condition 1 is false, then SUM(Number of records)
IF [City] = [PAR_SELECT_CITY] THEN
SUM([Number of Records])-[PAR_SELECT_QTY]
ELSE
SUM([Number of Records])
END
However, IF Statament does not accept to mix aggregation and not aggregation
How do I solve this issue?
As your error suggests, the issue is the mix of aggregate and "row level" data. In Tableau, you ideally want your row level data to be contained within an aggregate function.
i.e. sum(if true then 1 end) instead of if true then sum(1) end
For your example, you could try
SUM([Number of Records])
-
AVG(IF [City] = [PAR_SELECT_CITY] THEN [PAR_SELECT_QTY] ELSE 0 END)
Your PAR_SELECT_CITY also needs to return an aggregate number. If PARA_SELECT_CITY = 5 (for example) and your dataset contains 100 rows, the AVG(PARA_SELECT_CITY) will also be 5, whereas SUM(PARA_SELECT_CITY) would return 500. Therefore the AVG should work as an aggregate function that returns the desired value.

Creating a nested if statement. If cells K2 or D2 have certain words in

I have a formula right now that looks to cell K2 and writes the word "SKIP" in cell J2 if cell K2 is blank. Like below:
=if(ISBLANK(K2),"SKIP","")
What I want to do is add an additional check, which is, if cell D2 has the word "anonymous" in then keep the word "anonymous" in cell K2. Is this possible?
I tried this:
=if(D2="anonymous","SKIP","",if(ISBLANK(K2),"SKIP",""))
but get the error message "Wrong number of arguments to IF. Expected between 2 and 3 arguments, but received 4 arguments."
Can anyone help? Is Nested IF statements the right way to go? FYI I'm working in google sheets. Thanks.
For background, I have a google sheet that is feeding in user feedback. I am replying to these users via a mail-merge addon with different canned messages. K2 is blank until I manually categorise the feedback type which is added via data validation and until I do that I need J2 to have the word SKIP to ensure the mailmerge tool doesn't email them. Once I've categorised the row, J2 can have the word SKIP removed so that the mail merge tool can email that user. FYI another cell reads from K2 via vlookup to create canned messages. If K2 is anonymous, "SKIP" should remain.
IF statement takes only 3 parameters (logical_expression, value_if_true, value_if_false).
Based on the logic you gave, there's no need to use nested IF since we are modifying 2 different cells.
J2 - =iF(ISBLANK(K2),"SKIP","")
K2 - =IF(D2="anonymous", "anonymous", "")
But if you mean to populate the J2 with "anonymous" instead of K2, you can follow these steps below:
The first thing we have to check is the D2, if D2 have "anonymous" word, we put the word "anonymous" regardless if K2 is blank. Then, if D2 is empty, we will check if K2 is blank then put "SKIP" on it and 'blank' if not. If we will translate this into a IF Statement:
logical expression : D2='anonymous'
value if true : 'anonymous'
value if false : "IF(ISBLANK(K2),'SKIP', '')"
To summarize:
=IF(D2="anonymous","anonymous", if(ISBLANK(K2), "SKIP", ""))
From what you've written and added, I understand the following. You want:
If cell K2 is blank, make J2="SKIP".
If cell D2 = "anonymous", make J2="SKIP".
Values in D2 and K2 are changed manually by you (using a dropdown list?)
This is possible, with the following formula in J2:
=IF( OR( K2="", D2="anonymous"),"SKIP","")
Have I misunderstood anything?
Also, you've said that there might be different words in K2 or D2. Unless you provide us with all the possible words, and the outcomes you want in each case, we can't help you with a proper formula solution.
If you are still having issues, please share a copy of your sheet, since I am having trouble clearly understanding what you want to do.

Issue with multiple conditions in script editor

I've created a script editor for a google sheet that has multiple tabs. One if statement I can't seem to get working is - If sheet "Employee Evolution" column 8 EQUALS "Disqualified" AND column 13 is NOT EQUAL to "NO DATA", move the row to sheet "Disqualified" I've tried so many different ways to rearrange and can't get it to work.
**function onEdit(event) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if(s.getName() == "Employee Evolution" && r.getColumn() == 8 && r.getValue() == "Disqualified" && r.offset.getValue(0,5) != "NO DATA") {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Disqualified");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1,numColumns).moveTo(target);
s.deleteRow(row);**
I have no coding experience, so I'm having a difficult time understanding javascript documents that explain this stuff. Please help!
Below is the link to my spreadsheet
https://docs.google.com/spreadsheets/d/1vp46hMbmB5968cRW2BGhS66qqNhl91Llk8xeknlRuQc/edit#gid=0
Right now I only have the first if statement and else if statement set up with multiple conditions, but that is not working. When I populate the 8th column (H) with Disqualified and populate the 13th column (M) with anything at all, nothing happens. And, if I populate column H with Qualified and populate column M with Paid Search, nothing happens.
Basically I want the row to move to either the PPC tab or the Disqualified tab. However, I don't want the row to move until both columns H and M are populated with specific text. If column H says "Qualified" AND column M says "Paid Search" the row should move to the PPC tab. If column H says "Disqualified" AND column M says anything other than NO DATA (even Paid Search), the row should move to the Disqualified tab.
The problem I can't get past is that I need to have each if statement look at both columns before executing true.
I hope this makes sense and thank you for your help.
It's not possible to define if that if should be working or not based just on the code as we don't have that spreadsheet you're using.
But I do notice some things that maybe are wrong on yout assumptiong, for this break that if into :
s.getName() == "Employee Evolution" => Checks if the current sheet that you have active is called "Employee Evolution"
r.getColumn() == 8 => checks if the current column that you have active is column number 8 (column h)
r.getValue() == "Disqualified" => checks if the current cell that you have active is equal to Disqualified (must matcha case as well)
r.offset.getValue(0,5) != "NO DATA") => Checks if column offset by 5 (will be equal column 13 indeed) is different then "NO DATA" (also must match case)
And of course as this function is onEdit, so this code will only run when you change something on the spreadsheet.
So I suppose by reading that code is that whenever someone changes column 8 to "Disqualified" (must match the capital letters as well) and all the other criterias match, it should be moved to "Disqualified" sheet. Pay attention to all the case sensitive scenarios you have.
I think overall the code seems fine. Share the spreadsheet so we can check what might be going wrong.
PS: by something being active I mean that your cursor is clicked/selected that thing

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, ))}, ))

Tableau check for multiple IDs across 2 groups

I want to create a set in tableau, which will show either one of these two values: Y or N
2 already existing columns are here important, "VAT-ID" and "CUSTOMER-ID". the new column should check if a customer-ID has multiple VAT-IDs. If yes, the value "Y" should be displayed, else "N".
The table looks like:
customer-id VAT-id in-both
123456 EE999999999 Y
654321 AA999999999 N
666666 GG999999999 N
123456 KK999999999 Y
654321 AA999999999 N
any Help would be appreciated, I have tried IF [CustomerID] = 1 AND Count([VAT-ID]) > 1 THEN 'Y' ELSE 'N' END which didn't work.
You are close. For this you need an LOD (Level of Detail) expression. LOD expressions allow you to do calculations at a different granularity then the view is rendered.
You can use:
if
{fixed [Customer-Id]: countd([VAT-id]) } > 1
then 'Y'
else 'N'
end
The LOD is the {fixed...}. The way you read this is you want to count the distinct number of VAT-id per each Customer-id. (eg 123456 will return 2; all others will return 1). Then you just wrap that in an If statement.