IF is the most used Excel function out there. Here are 10 advanced IF tricks to take your formulas to next-level 🚀
In this article, you will learn:
- Only one of, two out of three type rules
- Between condition check with MEDIAN
- Replacing Nested IF with shorter function
- Using boolean logic to replace IF formulas
- Arrays with IF function
- Wildcard checks with IF function
- How to use IF formula in other places
- Conditional formatting
- Data validation
- Charts
Sample data for the examples
All examples in this article use below sample data. Assume it is in the range C8:G23
You can download this data alone for practice purpose from here.
Includes sample data for practice, completed Excel workbook
#1 - Only one of condition
Situation
Identify employees who are only one of gender=male or salary under $85,000
Formula
=IF(XOR(D8="Male",G8<85000),"Include", "Exclude")
Explanation
XOR function will return TRUE if an odd number inputs are TRUE, else FALSE.
So, our XOR(D8=”Male”, G8<85000) will be useful for checking only one of condition.
Note: XOR doesn’t work when you want to check only one of when you have more than 2 conditions. For that refer to next trick.
Also read: Either Or formula in Excel
#2 - Two out of Three Check
Situation
Flag employees when they meet any two out of below three conditions.
- Department is Website
- Year of join is 2019
- Salary is above $90,000
Formula
=IF((E8="Website")+(YEAR(F8)=2019)+(G8>90000)>=2,
"Include", "Exclude")
Explanation
The trick is in understanding Excel treats TRUE as 1 and FALSE as 0.
So, the expression (E8=”Website”)+(YEAR(F8)=2019)+(G8>90000)
will be converted a bunch of 1s & 0s and added up, depending on the details of employee.
We can then simply check if such number is >=2 to see if any two out of three conditions are met.
#3 - Using MEDIAN for Between Condition
Situation
Identify employees joined between 1-Jan-2019 and 30-Jun-2019.
Formula
=IF(MEDIAN(F8,DATE(2019,1,1),DATE(2019,6,30))=F8,
"Review","")
Explanation
Normally, we use AND() function to check for between condition. But, you can also use MEDIAN for this.
The pattern goes like,
=MEDIAN(your value, above, below) = your value
The above will be TRUE if your value is between above and below values.
For example, =MEDIAN(7, 3,9) = 7 is TRUE.
Read more: How to write BETWEEN formula in Excel
#4 - Replacing Nested IF functions
Situation
Calculate staff bonus based on below rules:
- 1% for Website staff
- 3 % for Sales staff joined in 2018
- 2% for others
Formula
=IFS(E8="Website",1%,
AND(E8="Sales",YEAR(F8)=2018),3%,
TRUE,2%)
Explanation
Nested IF functions can be hard to write and tricky to maintain. That is why, you should use the newly introduced IFS() function.
The syntax for IFS goes like this:
=IFS(condition1, value1, condition2, value2…)
But, IFS() doesn’t have ELSE option…?
Well, you can use TRUE as last condition to fix this.
In the above formula TRUE, 2% part handles the ELSE case beautifully.
#5 - Boolean Logic to avoid IF formulas
Situation
Calculate staff bonus based on below rules, but don’t use any IF formulas:
- 1% for Website staff
- 3 % for Sales staff joined in 2018
- 2% for others
Formula
=2% - (E8="Website")*1% + AND(E8="Sales",YEAR(F8)=2018)*1%
Explanation
You can use boolean logic checks to altogether avoid IF formulas. This works well when your outputs are numbers.
The above formula calculates staff bonus by using TRUE=1 & FALSE=0 notion.
Let’s test it out for below staff:
![]()
For Gigi:
- 2% – (FALSE)*1% + (TRUE)* 1% = 3%
For Curtice:
- 2% – (FALSE)*1% + (FALSE)*1% = 2%
Read more: Daniel Ferry’s excellent I heart IF
#6 - Checking if a value is in another list
Situation
Check if an employee is part of on call support team
(range: C32:C36)
Formula
=IF(COUNTIFS($C$32:$C$36,C8),"On call","Not on call")
Explanation
We can use COUNTIFS or MATCH functions to do this. I prefer COUNTIFS.
Just count if a given data point is in another list.
Why don’t we check >0?
Remember, Excel treats any number other than 0 as TRUE. So we don’t need to write COUNTIFS($C$32:$C$36,C8)>0.
#7 - Arrays with IF formula
Situation
Calculate median salary of website staff
Formula
=MEDIAN(IF(E8:E23="Website",G8:G23))
Explanation
When you use arrays in the IF formula, it will return an array of outcomes too.
So for eg. =IF({TRUE,TRUE,FALSE}, {1, 2, 3}, {“A”,”B”,”C”}) will return {1, 2, “C”}
We can use this powerful idea to calculate median salary of website staff too.
What about ELSE part? It’s missing no?
If you don’t mention the ELSE part of IF formula, it will simply return FALSE for those values.
So, in our case, we get
{FALSE;90700;48950;FALSE;FALSE;107700;…FALSE}
When MEDIAN reads those values, it will ignore the FALSEs and calculate MEDIAN for rest.
Read more: Calculating RANKIFS with Excel
Situation 2
Show all names of “Finance” staff in one cell, comma seperated.
Formula
=TEXTJOIN(",",,IF(E8:E23="Finance",C8:C23,""))
Explanation
This works same as the MEDIAN(IF()) structure. For more applications of this technique, see the Excel Risk Map
#8 - Wildcard based conditions
Situation
Identify if an employee’s name contains letters bo
Formula
=IF(COUNTIFS(C8,"*bo*"),"bo person","not a bo person")
Explanation
IF function is not aware of wildcards. But we can use one of the other wildcard aware functions inside IF to solve the problem. You can use either of XLOOKUP, XMATCH, MATCH, VLOOKUP, COUNTIFS for this.
I prefer COUNTIFS.
The COUNTIFS(C8, “*bo*”) will be 1 if name in C8 has bo in it, else 0.
Rest is self-explanatory.
Read more: Making VLOOKUP formula go wild | Not so wild lookups
#9 - IF formula with Conditional Formatting
Situation
Highlight employees that meet conditions specified in below cells.

Rule
=AND($E8=$J$50,$D8=$J$51)
Explanation
When checking rules in conditional formatting you don’t need to use IF formula. Just use the condition part of the formula alone.
Here is the result of our rule.

#10 - Using IF with Charts
Situation
Make a chart with employee salaries, but highlight staff making above average salary in a different color.
Process
- Add an extra column in your data and use IF formula to check if a person’s salary is above average.
- Make chart with both original salary & the new column.
- Overlap the bars (or columns) 100%
- Color them accordingly.
Formula
=IF(G8>AVERAGE($G$8:$G$23),G8,NA())
Outcome
Resources - File & Video
Includes sample data for practice, completed Excel workbook
Watch the video & learn these techniques
More on IF formula
Resources
Check out below tutorials to master IF formulas & business logic
Homework problems
Use these homework problems to sharpen your if muscle.
What is your favorite IF formula trick?
Share it in the comments. Let’s learn from each other.















15 Responses to “Modeling Interest During Construction (IDC) – Excel Project Finance”
Thanks again for a very helpful post.
I had a similar problem when trying to model a balance sheet and profit and loss projection. The problem was that interest expense (in P&L) was dependent on a cash shortfall (in BS) which had to be funded. The cash shortfall depended on how much interest was paid, so the mutual dependency made a circular reference.
I addressed it with a macro that calculated interest outside of the P&L, then pasted the calculated amount into the P&L as a value. The model was out of balance, but by repeating the pasting and calculating loop the imbalance reduced to zero. It was a bit messy, and had to be repeated every time a line changed - but it worked.
If I have to do it again I'll read this article again first and see if it can be done more elegantly.
Hi,
The use of a circular reference can be avoided in this case. Just make use of the geometric sum to calculate the interest required. I’ll walk through the example from the spreadsheet.
First calculate the cash needed each year without the interest expense. So you year 1 you need 55 Mn, year 2 105 Mn, and 190 Mn for year 3. The total amount to borrow for year 1 is then (50 Mn)/(1-interest_rate) = (50)/(1-0.1). For years 2 and subsequent the amount borrowed is the cash needed in that year plus the interest_rate times the amount already borrowed. For year 2 (105 + interest_rate * sum(previous debt raised))/(1-interest_rate)=(105+0.1*61.1)/(1-0.1).
This process avoids the need for a circular reference, and makes the calculation more stable.
Thanks,
Tristan
The question is for the year 1 in your case, the amount works out to 45 mn. However in the year 2 you have applied the loan amount as 61.1 mn.
Am I missing something ! Please help !
very helpful information!!!
using circular references and to make model more stable we can use combination of "IF" and "ISERROR" functions. i.e
=if(iserror(formula1),"",(formula1))
this formula will return blank value if there is any error otherwise give the result required.
I usually use this in my models and it makes them very stable......
🙂 🙂 🙂
@Terry: Thats right. Exactly same problem is seen in Interest - Cash cycle in P&L and Cash Flow statement as well. In our trainings on financial modeling in excel, we demonstrate using both the circular loops as well as the macros to take care of this problem. Circular loops have their own pitfalls. If the model enters into a state of error, the error percolates!
@Tristan: Thanks for pointing out. I agree with you that if circular loops can be avoided, they should be avoided.
@Yogesh: This is one way of avoiding the problem. Although circular loops have another problem that they make your sheet slower. Each time, there is a change in the sheet, all the calculations are redone. So if they can be avoided, they should be avoided.
Please note that this was an example (a large one indeed) and I didn't have space to speak about the pitfalls of this approach! I just wanted to illustrate an approach and am glad that some of you found it useful!
I think while posting, there is an error in the images! The last image should be flipped with the one that is posted in step VII!
I think you can try the following simple solution given by Microsoft itself to make the circular works:
Windows: Excel Options -> Formulas -> Put a tick on "Enable iterative calculation"
Mac: Excel -> Preference -> Calculation ->Put a tick on "Limit iteration"
You can change the maximum number of calculation iterations as well as the maximum changes which iteration stops for goal seeking or for resolving circular references based on the number you type in the maximum change box.
Thank you.
Hey All
I heard that we can take care of the circularity with the help of macro for IDC. Can anybody help on the steps to construct the macro for the same.
Regards
Vinay
Hi Vinay,
If you look closely, you are essentially copying the values from the interest calculation to the IDC in project cost.
Basically you can record a macro, that takes the values from interest and pastes special the values in IDC row in project cost.
Then you can run that recorded code in a for loop.
Hope this helps.
Thanks Param for reply.
But before calculating interest, i need to provide for Upfront Equity and Equity, which are essentially part of total project cost. Hence, i need to put in Upfront Equity and Equity to calculate the IDC which is again hitting the total project cost.
Bit of confused on how to remove this circular reference.
Regards
Vinay
Wow, this was a brilliantly simple post. I was looking online for a while before I found this page. Never seen this been explained so beautifully yet so crisply before. Thanks for saving my ass at work! (i'm relatively new to finance + modeling)
I'm not sure why but this web site is loading very slow for
me. Is anyone else having this issue or is it a problem on my end?
I'll check back later and see if the problem still exists.
[…] Project Finance Modeling using Excel – Part 1 & Part 2 […]
I have been reading your blog since my college days. Today, I'm writing just to say thanks.
We have calculated Financial Rate of return of a hydropower projects, and the observer has raised an observation regarding Total Project cost with IDC Rs. 8616.01 million (PKR) and with-out IDC 8352.46 million (PKR). How does the Financial nalysis be calculated on the basis of with-out IDC Or With IDC?????
Please helpf. if possible to spare some time.