I am trying to develop a simple expiration date with conditional highlighting. I've set up the column I to an IF statement based on a logic test in column G, drawing value from Column A. Formula is currently:
=IF(G2="N", A2+7,A2+60)
Problem is, I'm making this for a complete excel newbie so I need it foolproof. I want column I to remain blank as long as either cells in the corresponding column A or G are blank (not relevant which, they'll both be filled together). I've tried a few nested and "AND" statements to no avail.
You need to use OR to test if either A2 or G2 is blank using the ISBLANK function:
=IF(OR(ISBLANK(A2),ISBLANK(G2)),"",IF(G2="N",A2+7,A2+60))
If so, you can return "" if either input is blank, and if both are populated then go ahead and use your original formula.
One option is to use COUNTA function to determine how many cells are populated and only use the IF function if the result is 2, e.g.
=IF(COUNTA(A2,G2)=2,IF(G2="N",A2+7,A2+60),"")
Related
Im trying to count the duplicated values between the 2 row so im using the formula as you can see it in the image =SUM(COUNTIFS(E4:S4,{"1","2","3"}))
so I have to write the numbers so I dont want write the numbers I want select the cells instead, any formula would do that? I already searched and tried many things but nothing seem to work
Put those values in cells - and refer to those cells as condition.
Next level: insert those values in a table, that you eg. call FilterBy and the column values
Then you can us this formula:
=SUM(COUNTIFS(E4:S4,filterBy[Values]))
Hat I don't understand: why are you using SUM - like this, it doesn't make sense, as COUNTIFS returns one value.
If you want to some all filtered values then you need this formula:
=SUM(SUMIFS(E4:S4,E4:S4,filterBy[Values]))
I have multiple input values in excel that should be used to dynamically generate an output in a cell.
For example in cell B1:B15 I have 15 checkboxes, and in cell A1 I have a dropdown menu with multiple values. Now I want to take the value of cell A1 and then based on the checked boxes in B1:B15 I want to generate an output (a notition with an image). As you can imagine, there's quite a lot of possible ways in this 'graph'. What would be the easiest way to implement such a thing in excel, in such a manner that it is easy to expand upon?
So for example:
If (a1=="wood" and (b1==checked, b2==checked, b5==checked), "Output1")
If (a1=="wood" and (b1==checked, b5==checked, b7==checked), "Output2")
... etc.
I don't know of any way to manipulate images in excel just using formulas.
That being said, I think there might be a way to get a result similar to what you are looking for.
If you create a 2 column table of cells (I'm using c2:d5), first column checks column B for the specifics you want (ex: c2 will look at cells B1, B2, B3, and return "True" if they are all "Checked"), then all you have to do is create an output cell that says =vlookup("True",c2:d5,2,false), then it will return what you put in column d next to the check in column c.
If you want a default option if none of the conditions work out, put "True" on the last line of the table, instead of another condition. Vlookup finds the first matching condition, so as long as its the last option, it will only be found if none of the rest match "True".
if you want this to happen only if A1 = "Wood", then put a If statement around it. (=IF(A1 = "Wood", Vlookup(), [insert what you want if its not equal to "wood"]))
If you want a physical change to the cell you typed "wood" into, you can use conditional formatting: create a custom format, choose the format, type the formula as a true/false if statement. (There may be other ways to get it to work, but I don't know of any other way to make a conditional format), EX: =IF(AND($A$1="Wood",vlookup("True",c2:d5,2,false)=[result]),TRUE,FALSE)
I'm trying to conditionally format a column of cells based on whether the combination of two other columns appear in a Table.
Here is a link to the test workbook I am playing with and screenshots below for those that don't like clicking strangers links!
https://1drv.ms/x/s!Al1Kq21dFT1ij4ktFd0mzBniNX00tQ?e=L6aQm4
On the far left is an Excel table ([Table1]) that contains a list of valid combinations of [Category] and [Item]
Columns E&F contain some sample data to test against
Column G is the number of matching combinations I expect to return from a COUNTIFS() function
Column H is simply the same formula compared to 0 so I get a boolean result.
The actual formula to get the result shown in Column H is
=COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0
All the above works as expected.
In Column J is just some literal text with conditional formatting. The condition is simply =H4, again this works as expected.
Now to the problem...
I want to avoid having the helper column (H) so I thought I could just use the same formula that I used in column H, as my condition formula.
So, I tried to use this in the conditional formatting formula dialog.
=COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0
and with parantheses
=(COUNTIFS(Table1[Category],"="&E4, Table1[Item],"="&F4)=0)
Unfortunately, this results in the generic "There's a problem with this formula" error message.
If might be that there are some limitations with conditional formatting formulae that I'm not aware of (I'm no Excel guru, I'm a SQL developer really).
BTW: I need to stick with using a table as my real-world scenario is that there will be several tables, all populated from a database via a separate process with lengths varying from 2 or 3 entries to potentially thousands.
I would appreciate any help, even if it's just to say "You can't do this, you'll need to use your helper column..."
Thanks for looking...
Instead of writing the formula multiple times at multiple instances, I'd like excel to detect the formula based on a defined reference.
Column F should be calculated based on the Operation defined in column E. In this example, I can use IF() as I only have 4 Operations but this question is linked to another scenario where I have over 20 Operations.
I have all the formula's ready but I'd love to understand if there is way to use the appropriate formula based on "Operation" Column.
I would approach your situation by labeling your Column A, B, C, or X, Y, Z or something similar for consistent readability with your formulas.
Second thing I would do is build your formula table similar to what you have except that I would change your formula from being sheet and cell references to being you variable references:
A+B+C+D
A-B-C-D
A/B/C/D
A*B*C*D
Make sure the formulas are written with operators the same way you would if you were using a cell reference.
Then based on your lay out on sheet 3 I would use a VLOOKUP:
=VLOOKUP(E2,SHEET4!$A$2:$B$5,2,0)
Place that in F2 and copy down. That will tell you if you are pulling the right formula or not.
In G2 use the following:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(F2,"A",A2),"B",B2),"C",C2),"D",D2)
Check this to see that your substitution of your values for your variables is correct.
Then select cell H2 to make it the active cell. Then go Formula Ribbon and select Define Name from the Definied Names section.
Give a name for your formula such as ANSWER.
For your formula use
=evaluate(G2)
once you have added the defined formula to the list of formulas go to cell H2 and enter the following:
=ANSWER
now if you want to avoid all those helper columns, you can substitute one formula into the other.
Can't believe I don't know this, but is there a way to avoid repeating a formula in an if statement if the logical test is dependent on it?
i.e.
=IF((SUMIFS formula)=0,"",SUMIFs formula)
I want to replace that SUMIFS function in the false scenario with something short that will tell it to just programmatically repeat the formula it originally tested for. Repeating the formula twice has to have detrimental effects on processing speed. Negligible, maybe, but want to go for best-practices here. Thanks.
You can force an error like #DIV/0! and then use IFERROR, e.g.
=IFERROR(1/(1/SUMIFS_formula),"")
You can assign a Name to a formula and use the Name..............See:
Assigning a name to a formula
Relevant excerpt -
For example, let's suppose we frequently use a formula like:
=SUM(A1:A100)-SUM(B1:B100) and this resides in A101 and is copied across many columns on row 101. It would be better in this case to
create a custom formula that does this in each cell on row 101. Here
is how;
1) Select cell A101 (this is vital).
2) Go to Insert>Name>Define and
in the "Names in workbook" box type: SalesLessCosts
3) Now click in
the "Refers to" box and type: =SUM(A1:A100)-SUM(B1:B100) then click
Add.
Now you can replace the formula in cell A101 with: =SalesLessCosts.
You can also copy this across row 101 and it will change its relative
references just as the formula =SUM(A1:A100)-SUM(B1:B100) would. The
reason it does this is all down to the fact we selected A101 before
going to Insert>Name>Define and used relative references in
=SUM(A1:A100)-SUM(B1:B100) when we added it to the "Refers to" box.
If all you need to do is hide zeroes, there is an easy way:
Select all cells where you wish to hide zeroes
Go into Custom Number Formatting
Set format to "General;General;"
The custom formatting has a structure of [positive numbers];[negative numbers];[zeroes]
By making the last part blank you are effectively hiding zeroes, but showing everything else.
The advantage over conditional formatting is that you can use this on any background.
A neat trick which I sometimes use is to hide the cell value completely by using a custom format of ";;;". This way you can put images inside the cells, like the conditional formatting ones, and not see the value at all.
Try using the SUBSTITUTE function like this :
=SUBSTITUTE( VLOOKUP( H4; $D$5:$E$8; 2; 0 ); $H$1; $I$1 )
Here is an example:
Here the formula I don't want to repeat twice is the VLOOKUP function.
The result of VLOOKUP is a string found in another table (ex : "Green").
I want to check if that string matches a specific string value in $H$1 (here, "Yellow").
If it does, SUBSTITUTE replaces it with$I$1 (the error string you want. Here, "FORBIDDEN").
If it doesn't, it displays the VLOOKUP result string (the normal authorized output, like "Green").
This is useful for me because my actual formula is quite long, so I don't want to write it twice.
I also dont want to use two different cells, because I'm already applying this formula on 10 columns, meaning I should add an extra 10 columns to make it work.
In some scenarios, MAX() or MIN() can do a wonderful job.
E.g., something like this:
=IF(SUMIFSformula>0,SUMIFSformula, 0)
Can be shortened to this:
=MAX(0,SUMIFSformula)
The LET formula can be used for this exact scenario. You can define the formula as a variable and then within that same cell you can reference the variable in your formula.
The LET formula format looks like this:
=LET(name,name_value,calculation)
SUMIFS Example
Here's how it would work with your SUMIF example so that you don't have to repeat the formula:
In this screenshot we have an array A1:B7. We want to sum the values (Col B) if the name in ColA is "apple".
For this we have a standard SUMIFS formula of
=SUMIFS(B1:B7,A1:A7,"apple")
The formula is showing in E2. The result is shown in E3.
To put this into the IF statement without having to repeat the formula we can use LET as shown in the screenshot.
We create a variable with the SUMIFS formula as the value of that variable. We then write our IF statement using the variable name instead of rewriting the formula multiple times.
=LET(name,name_value,calculation)
Variable name: sumapples
Variable value: SUMIFS(B1:B7,A1:A7,"apple")
Calculation: IF(sumapples=0,"",sumapples)
Put together in the LET function it looks like this:
=LET(sumapples,SUMIFS(B1:B7,A1:B7,"apple"),IF(sumapples=0,"",sumapples))
This LET function can be used in any Excel formula, and is very useful for shortening long formulas that have repetition.
Optional: Extra complexity
If you want to you can get extra complicated by naming multiple variables.
=LET(name,name_value,name2,name_value2,calculation)
Since Excel 2007, the IFERROR statement does what the OP asked. From the help file:
Description:
Returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula. [italics mine]
Syntax:
IFERROR(value, value_if_error)
I've since realised that this was already answered by #barry houdini above.
Here is a hack - depending on whether you are just interested in the displayed value, or whether you need to use the value in another formula:
Put your SUMIF formula in the cell (without the IF part)
Create a conditional formatting rule which sets the font color to the background color when the cell value is 0
And hey presto, you get the desired result.
As I said - it's a hack, but it does prevent the double evaluation.
There is no "clean" solution that I am aware of.