ifs

Public Schedule Face-to-Face & Virtual Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel Training and help » IFs

IFs

resolvedResolved · High Priority · Version Standard

IFs

Hello,

It's easier to attach an excel spreadsheet here to explain this...

I cannot understand Formulas to compare the date and the way of calculations.

The formula uses for to calculate monthly amount. (i.e. the period : 15/04/2021-14/04/2022, £4660. So April amount is £4660/365daysx16days=£204.27, May amount is £4660/365daysx31days=£395.78....)

In the excel spreadsheet, the input data and the formulas are as following:

Period from 15/04/2021(C8), to 14/04/2022(D8), Total days: 365 (E8), Value £4660 (G8), Brought/Forward amount(i.e.£3676.93) (H8), Carry/Forward amount (i.e.£3281.15) (J8), Prepaid date [Formula:=IF((D8-$O$1 )<0,0, (D8-$O$1))](L8), Release amount [Formula:=IF(((J8-($G8*L8/$E8))*-1)<0, ROUND(((J8-($G8*L8/$E8))*-1), 2), "")](N8), the month end date(i.e.31/08/2021)(O1), Carry/Forward amount[Formula:=ROUND(SUM(J8:N8),2)] (i.e.£3111.37) (O8)

The first formula (L8) if() is comparing the dates, end date 14/04/2022 - the month end 31/08/2021, the future date is bigger than past date, so the answer is more than 0, however the formula uses "<0" I do not get it. but it shows "226" days, why?

The second formula(N8) shows "£-395.78" it needs to be in minus amount, therefore I do understand the "*-1" in the round formula, however I do not understand this part: (J8-($G8*L8/$E8))*-1)<0, why does it need "*-1"?

I will reuse the formulas for every months, however I do not understand them, I cannot change the cells in the formula.

Please could you explain these?

Thank you.




RE: IFs

Hi Mieko,

This question was posted to our 'Improve the forum' thread, which is not monitored regularly.

I have moved it to our Excel forum and will ask one of our trainers to have a look at it ASAP.

Apologies for the delay.

Regards,
Rich Talbot
STL

Edited on Sat 4 May 2024, 10:39

RE: IFs

You're right, there seems to be a logical error in the first formula (L8) and some room for improvement in the second formula (N8) for calculating monthly amounts in your spreadsheet.

As always, use code with caution.

Let's break them down:

Formula (L8): Prepaid Date

Error: The formula uses <0 (less than zero) to check if the end date (D8) is after the month-end date ($O$1). This should be >0 (greater than zero) for the logic to work as intended.
Calculation: Even with the error, it calculates the difference between the end date (D8) and the month-end date ($O$1) and returns 226 because April 14, 2022, is 226 days after August 31, 2021.

Formula (N8): Release Amount

Logic: This formula calculates the release amount for the month. However, there's a nested IF statement with a confusing structure.
Breakdown:
(J8-($G8*L8/$E8))*-1: This part calculates the remaining amount after subtracting the "prepaid" amount for the month (portion of the total value based on prepaid days).
$G8: Total value (£4660)
L8: Prepaid days (incorrectly calculated due to the error in formula L8)
$E8: Total days in the period (365)
*-1: This multiplies the result by -1 to get a positive value for the release amount since the calculation results in a negative number (money being spent).
IF statement: This checks if the result after multiplication by -1 is less than zero (negative).
If it's negative (meaning the remaining amount is positive), it rounds the result to two decimal places and displays it as the release amount.
If it's not negative (meaning there's no remaining amount), it displays an empty string ("").

Explanation and Improvement:

The first formula (L8) needs correction:

=IF((D8-$O$1) > 0, (D8-$O$1), 0) // Change "<0" to ">0" and add a 0 for no prepayment

This checks if the end date (D8) is after the month-end date ($O$1) and returns the difference or 0 if not.

The second formula (N8) can be simplified:

=ROUND($J8 - ($G8 * L8 / $E8), 2) // Remove unnecessary nesting and "-1"

This directly calculates the remaining amount by subtracting the "prepaid" amount and rounds it to two decimal places.

Using the Formulas for Different Months:

Since you can't change the cell references within the formulas, you'll need to copy and paste them for each month, adjusting the month-end date reference ($O$1) in each formula. For example, for May, the month-end date reference in both formulas would be changed to September 30th, 2021 (cell reference can be adjusted based on your spreadsheet).

This should give you a more accurate calculation of the monthly amounts based on the total value and prepaid days.

 

Training courses

 

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Go to source of a cell

The default setting in Excel is when you double click in a cell it actives the formula in the cell. If you have created a link and want to directly go to that link (say if on another sheet, click on Tools -options and take off the tick for eidt it directly in cell

View all Excel hints and tips


Server loaded in 0.07 secs.