=IF( and calculations within the same function

thirdeye85

New Member
Joined
Aug 11, 2021
Messages
23
Office Version
  1. 2019
Platform
  1. MacOS
I have a question about nesting calculations within the same =IF( function. For instance, I10 has a nested (IF function as follows: =IF($E10=I$1,$G10,IF($F10=I$1,-$H10,0))

This basically says that if the cell $E10=I$1 then G10 will be a positive number and if $F10=I$1 then it will be a negative. This functions well in its own right. However, I would like to attach the following calculation to this function (J14 within spreadsheet) =$G10-($G10*0.026)-0.1. This should only be calculated if B10 = CC, otherwise the calculation should not be performed and only the first two IF logical tests should apply.

I think all I need to do is add a third logical test that states that EVEN IF the first two are true, the last test given that B10=CC will supersede the previous arguments.

Am I going at this the right way?

And just some context the formula is a calculation of credit card fees that are tacked onto a dollar amount of $80.00; if CC is not input under type (B10) but rather CASH then the formula would not be required to calculate those fees.

Thank you for your help!

Double Entry Bookkeeping Final.xlsx
ABCDEFGHIJ
1NotesTypeMonthDateAccount DebitedAccount Credited Debit Credit IncomeSouthState
2
3
4
5
6
7
8
9
10Doe, JoeCC89/17/21SouthstateIncome$ 80.00$ 80.00-$80.00$80.00
11Doe, JaneCASH89/17/21SouthstateIncome$ 80.00$ 80.00-$80.00$80.00
12
13
14$ 77.82
Sheet2
Cell Formulas
RangeFormula
I10:J11I10=IF($E10=I$1,$G10,IF($F10=I$1,-$H10,0))
C10:C11C10=MONTH(Ledger3[@Date])
J14J14=$G10-($G10*0.026)-0.1
 
OK try this in cell I10

Excel Formula:
=IF($B10<>"CC",
         IF($E10=I$1,$G10,IF($F10=I$1,-$H10,0)),
         IF($E10=I$1,$G10 - ($G10*0.026)-0.1,IF($F10=I$1,-($H10 - ($H10*0.026)-0.1),0)))
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
This works like a charm, thank you so much!

Can you just briefly explain this top part.
=IF($B10<>"CC", This instructs the formula if B10 does not equal CC, but what is it instructing it to do?

And this bottom part:

IF($F10=I$1,-($H10 - ($H10*0.026)-0.1),0)))

Thank you for your time in helping =)
 
Upvote 0
Can you just briefly explain this top part.
=IF($B10<>"CC", This instructs the formula if B10 does not equal CC, but what is it instructing it to do?

This part of the if statement is simply a switch.
You requirement is to use a different formula if B10 = "CC".
For ease of reading the 1st line logic is reversed so that:-
If it B10 is not CC then do your original logic.
=IF($B10<>"CC",
*** not CC so just do the original logic ***
IF($E10=I$1,$G10,IF($F10=I$1,-$H10,0)),
*** ok it is CC and needs the new formula ***
IF($E10=I$1,$G10 - ($G10*0.026)-0.1,IF($F10=I$1,-($H10 - ($H10*0.026)-0.1),0)))

IF($F10=I$1,-($H10 - ($H10*0.026)-0.1),0)))
part of IF($E10=I$1,$G10 - ($G10*0.026)-0.1,IF($F10=I$1,-($H10 - ($H10*0.026)-0.1),0)))

Since G10 and H10 are both positive, you can use the Exact same formula for both,
$G10 - ($G10*0.026)-0.1
$H10 - ($H10*0.026)-0.1
But at the end of that if you use G10 you want it to be the positive and if you used H10 you want it to be negative so take the formula wrap it in () to treat it a single entity and multiply it by -1
-1*($H10 - ($H10*0.026)-0.1)
which you can simplify to
-($H10 - ($H10*0.026)-0.1)

Since your 2nd question included the If statement, this alignment may help
1632365173629.png
 
Last edited:
Upvote 0
"If it B10 is not CC then do your original logic."

How does the formula you created know that though? Is it the order in which you placed the equations,

=IF($B10<>"CC",
IF($E10=I$1,$G10,IF($F10=I$1,-$H10,0)),
IF($E10=I$1,$G10 - ($G10*0.026)-0.1,IF($F10=I$1,-($H10 - ($H10*0.026)-0.1),0)))

I suppose if you did this, it would not work:

=IF($B10<>"CC",
IF($E10=I$1,$G10 - ($G10*0.026)-0.1,IF($F10=I$1,-($H10 - ($H10*0.026)-0.1),0))),
IF($E10=I$1,$G10,IF($F10=I$1,-$H10,0))

Is there an order of operations from excels point of view?
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top