# Two-Condition IF Formula

#1

What is the syntax for an IF statement that only generates output if two conditions, in two fields, are met?

Two 'finds' in filterbyformula API URL
#2

https://support.airtable.com/hc/en-us/articles/221564887-Nested-IF-formulas describes in detail how to nest `if` statements. You could also use an `if` and an `and`.

#3

To output one value if two conditions are true, and another value otherwise:
`IF(AND(Condition-1, Condition-2), Value-If-Both-Are-True, Value-If-Either-Are-False)`

#4

Hmm.

Right now I have a field that creates an underscore if the referenced field contains data. Itâ€™s generating a separator for auto-filenaming.

IF(SEGMENT1 = 0, â€śâ€ť,"_")

But it only works when the field that contains data for the second segment of the filename, the one after the underscore, is present.

When the second segment field is empty, I need the first field to return nothing.

Something like (and pardon my french): IF((SEGMENT1 = 0, â€śâ€ť,"_") BUT(IF(SEGMENT2 = Y, â€śâ€ť,"")))

#5

In that case you may need to use OR() to combine two conditions if either are true (used just like AND otherwise), or NOT() to reverse a single condition. Try different combinations of those. For example,

IF(OR(Condition-1, NOT(Condition-2)), Value-1, Value-2)

#6

Is it possible to create a conditional IF formula to perform a calculation IF a certain condition is met? I have a CHARGES column, a PAYMENTS column and a DISCOUNT column. I want to creat a formula to calculate the discount IF there is a value entered into the PAYMENTS column. Other wise, the formula (CHARGE-PAYMENT) calculates a discount of the full charged amount. Thoughts?

#7

Iâ€™m not exactly sure this is what you are intending, but the following does do something kind of like you describe:

``````IF(
{Payments},
({Charge}*{Discount})-{Payment},
{Charge}-{Payment}
)
``````

This assumes `{Payments}` is, say, a payment made at the time of purchase, which triggers some sort of percentage discount, while `{Payment}` is a newly received payment. Based on those assumptions, the formula applies the discount, if applicable, and then subtracts the amount of the received payment. If the purchaser does not qualify for the discount, it subtracts the payment from the full charged amount. In either case, the result is the outstanding balance.

If you canâ€™t warp that to your actual needs, let me know, and Iâ€™ll try again.

#8

Thank you for your response! Its close but not quite. The discount is actually a WRITEOFF and will be equal to the CHARGE minus the PAYMENT only IF a payment is made/entered. If there is no payment entered, the writeoff should not be caculated (as it simply calculates the full CHARGE minus a 0 PAYMENT to give me a WRITEOFF amount equal to the orignal CHARGE which is not what I want).

#9

Well, the standard `IF()` statement structure would look like this:

``````IF(
{Payment},
[What you want if a payment was received],
[What you want if no payment was received]
)
``````

(Itâ€™s not a multi-condition `IF()` as the posting initially discussed.)

So essentially youâ€™re looking at this, possibly with a second clause:

``````IF(
{Payment},
{Charge}-{Payment},
[What you want if no payment was received]
)
``````

If you donâ€™t want a value when no payment is received, you could just use this:

`IF({Payment},{Charge}-{Payment})`

#11

Thank you!! I think that will work. I appreciate the help!