I'm trying to build an IF formula, where I compare two dates, but my formula means same dates would be different.
So, I have in A2 a date, like 2019-11-04.
In B2 I have a date like 201945.
In A3 I check the week number with =isoweeknum(A2) and get 45.
In B3 I check the week number with =MID(B2; 5; 2) and get 45 too.
Then i try to compare them with =IF(((isoweeknum(A2))=(MID(B2;5;2))); "OK"; "different numbers") - but get different numbers.
On trying to write the formula as =IF(a3=b3; "OK"; "different numbers") I get different numbers too.
Why Sheets treat it as different? How should I write the formula so, that these same values are recognized as same?
MID auto-converts stuff to string (Plain text) so try:
=IF(ISOWEEKNUM(A2)=MID(B2; 5; 2)*1; "OK"; "different numbers")
Related
I am trying to compare two formula (calculated) cells in Google Sheets but I am getting: Error - Formula parse error.
The two cells are:
=IF(OR(ISBLANK(E5), ISBLANK(H5)),"", E5-H5)
=IF(OR(ISBLANK(E5), ISBLANK(J5)),"", E5-J5)
And the cell I am trying to compare them in is:
=IF(K5==K4, "yes", "no")
An help on how to compare these cells?
use just one = sign:
=IF(K5=K4, "yes", "no")
Tested your scenario and found out that if you have values on E5 and H5, then it works as long as it is numeric. Do something like
=IF(AND(ISNUMBER(E5), ISNUMBER(J5)), E5-J5, "")
So, if both cells are numbers, we subtract them, otherwise we have an empty value.
I'm new in this world. As you can see in the picture, I key in function at B1 and I want B1 to return 1 if A1 data is time. But it kept of giving me 0. At the same time, I want if there are no value or N/A, it must return 0. What should I key in? I do understand that if using =ifna("A","1","0"), but that still does not return me anything for if there are any data.
Format your column A to "Time"
Paste formula to B2: =IF(ISDATE(A1);1;0)
Note: I'm using Norwegian formatting/settings. For english formatting/settings, change ";" with "," in formula.
Why your formula won't work:
Since you use "" with your hh:mm:ss like this: "hh:mm:ss" - you're asking your formula to look for exactly that. Your formula will only return TRUE if A1 = hh:mm:ss (in text)
In IF-statements, do not use "" for returning numbers og TRUE/FALSE.
Your formula: if(A1="hh:mm:ss","1","0)
What needs to be changed in TRUE/FALSE part: if(A1="hh:mm:ss",1,0)
-- Tho, you need to ask if A1 is a date: =IF(ISDATE(A1),1,0)
To count for N/A - put IFERROR in formula: =IFERROR(IF(ISDATE(A1),1,0)0)
I want this formula to calculate a date based on input from two other dates. I first wrote it for a single cell and it gives the expected results but when I try to use ARRAYFORMULA it returns the wrong results.
I first use two if statements specifycing what should happen if either one of the inputs is missing. Then the final if statement calculates the date if both are present based on two conditions. This seems to work perfectly if I write the formula for one cell and drag it down.
=IF( (LEN(G19)=0);(U19+456);(IF((LEN(U19)=0) ;(G19);(IF((AND((G19<(U19+456));(G19>(U19+273)) ));(G19);(U19+456))))))
However, when I want to use arrayformula to apply it to the entire column, it always returns the value_if_false if neither cell is empty, regardless of whether the conditions in the if statement are actually met or not. I am specifically talking about the last part of the formula that calculates the date if both input values are present, it always returns the result of U19:U+456 even when the result should be G19:G. Here is how I tried to write the ARRAYFORMULA:
={"Date deadline";ARRAYFORMULA(IF((LEN(G19:G400)=0);(U19:U400+456);(IF((LEN(U19:U400)=0);
(G19:G400);(IF((AND((G19:G400<(U19:U400+456));(G19:G400>(U19:U400+273)) ));(G19:G400);(U19:U400+456)))))))}
I am a complete beginner who only learned to write formulas two weeks ago, so any help or tips would be greatly appreciated!
AND and OR are not compatible with ARRAYFORMULA
Replace them by * or +
Try
={"Date deadline";ARRAYFORMULA(
IF((LEN(G19:G400)=0),(U19:U400+456),
(IF((LEN(U19:U400)=0), (G19:G400),
(IF((((G19:G400<(U19:U400+456))*(G19:G400>(U19:U400+273)) )),(G19:G400),
(U19:U400+456)))
))
)
)}
Keep in mind you cannot use AND, OR operators in an arrayformula, so you must find an alternative method such as multiplying the values together and checking them for 0 or 1 (true*true=1)
I am gathering based on your formula's and work that you want to have the following:
If G19 is blank show U19 + 456
If U19 is blank show G19
If G19 is less than U19 + 456 but greater than U19 + 273 show G19
Otherwise show U19 + 456
I'm not too sure what you want to happen when both columns G and U are empty. Based on your current formula you are returning an empty cell + 456... but with this formula it returns an empty cell rather than Column U + 456
Formula
={"Date deadline";ARRAYFORMULA(TO_DATE(ARRAYFORMULA(IFS((($G19:$G400="")*($U19:$U400=""))>0,"",$G19:$G400="",$U19:$U400+456,$U19:$U400="",$G19:$G400,(($G19:$G400<$U19:$U400+456)*($G19:$G400>$U19:$U400+273))>0,$G19:$G400,TRUE,$U19:$U400+456))))}
Source data:
Market Platform Web sales $ Mobile sales $ Insured
FR iPhone 1323 8709 Y
IT iPad 12434 7657 N
FR android 234 2352355 N
IT android 12323 23434 Y
Is there a way to evaluate the sales of devices that are insured?
if List.Contains({"iPhone","iPad","iPod"},[Platform]) and ([Insured]="Y") then [Mobile sales] else "error"
Something to that extent, just not sure how to approach it
A direct answer to your question is
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
SumUpSales = Table.AddColumn(Source, "Sales of insured devices", each if List.Contains({"iPhone","iPad","iPod"}, _[Platform]) and Text.Upper(_[Insured]) = "Y" then _[#"Mobile sales $"] else null, type number)
in
SumUpSales
However, I would like to stress you few things.
First, it's better to convert values in [Insured] column to boolean first. That way you can catch errors before they corrupt your data without you noticing. My example doesn't do that, all it does is negating letter case in [Insured], since PowerM is case-sensitive language.
Second, you'd better use null rather than text value error. Then, you can set column type, and do some math with its values, such as summing them up. In case of mixed text and number values you will get an error in this and many other cases.
And last.
It is probably better way to use a pivot table for visualizing data like this. You just need to add a column which groups all Apple (and/or other) devices together based on the same logic, but excluding [Insured]. Pivot tables are more flexible, and I personally like them very much.
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, ))}, ))