# What change can I make to this formula to produce the desired output?

I would like to make a change to this formula in Excel.

=F297+D298-E298

If the field in D and E are both blank - then the output be blank.
Only if either field D or E are populated, then the output should reflect the initial amount in F297 plus any changes.

How can this be changed?
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Microsoft Excel ExpertCommented:
=if(or(d298<>"",e298<>""),sum(F297+D298-E298),"")

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

What if both D and E are populated?
Network ManagerCommented:

=if(or(d298<>"",e298<>""),sum(F297+D298-E298),"")

should be

=if(AND(d298<>"",e298<>""),sum(F297+D298-E298),"")

Only I think what I have is:

=IF((AND(D298<1, E298<1)),0,F297+D298+E298)
Author Commented:
if D and E are populated - or whether D alone is populated or E alone is populated - then the output must be visible
Network ManagerCommented:
The formula I provided will only do the calculation if both D and E are not less than 1. It will not do the calculation if D and E is a negative number or any part of a number below 1 (0.8 for instance)
Author Commented:
I see.  The formula should be adjusted if any amount if populated in either D or E or both, even negative amounts.
Is this possible?
Network ManagerCommented:
Do you want it anything but "0"?

=IF((AND(D298<>0, E298<>0)),F297+D298+E298,0)

This will place a "0" only if either D298 or E298 is "0" or blank, otherwise will perform the calculation
Network ManagerCommented:
Wait,  working on an error.  This formula will do the calculation as long as there is a value not equal to "0" in both but not if there is a value in either.

I think we are back to the OR instead of the AND.

=IF((OR(D298<>0, E298<>0)),F297+D298-E298,0)    (noticed I have been using a "+" instead of "-" in the last part of the calculation)

or again what Professorjimjam originally posted:

=if(or(d298<>"",e298<>""),sum(F297+D298-E298),"")

The second will nothing in the field where mine puts a "0"
Author Commented:
Thanks.  Nothing in the field ia the desired output if D and E have nothing in their fields simultaneously.
Network ManagerCommented:
Then I suggest you go with the first solution provided by Professorflimflam.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.