• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Petrol Spreadsheet

cyliyu

Member
I created a petrol spreadsheet to keep track of the petrol pumped in 2 counties.
The final result will combine and compiled based on country one.
Basically, I am using the "IF" statement and seeking advise if there is a better way to improve it.
 

Attachments

  • Book1.xlsx
    20.7 KB · Views: 12
Looks good here. All on one sheet - easy to enter - easy to review.

Is there anything you don't like about your creation ?
 
Firstly, I tend to use a table structured references for gathering information of this kind. This is because I can read a formula like
= [@LPumped1]+[@LPumped2]
and have a fair idea what is going on and, hence, be reasonably confident that the correct references have been selected. Sure
=E8 + L8
is shorter but it lacks meaning, in this case, conceals a deliberate error. The formula
= [@LPumped1]+[@Mileage2]
would have made such 'fat-finger' errors more obvious.

A second trick that I use is to shorten
= IF( [@Date]="", "", (1-[@[%Disc1]]) * [@LPumped1] * [@PerLCost1])
by using the fact that a date will be processed as TRUE and a missing date will be treated as FALSE. This allows you test for the active condition and leave the fallback to the second part of the statement
= IF( [@Date], (1-[@[%Disc1]]) * [@LPumped1] * [@PerLCost1], 0 )

Once one gets to the right of your calculated table, you seem to disappear down innumerable rabbit holes of IF clauses. Several of the formulas will evaluate perfectly well even when referencing zeros (better than null strings), so it is possible to work with fewer calculation branches. Tests are needed to trap 0/0, #DIV0! errors and you might decide to use a custom format (or a sheet setting) to avoid displaying non-significant zeros.

Ultimately though, you need to be happy working with your spreadsheet solution!
 
Looks good here. All on one sheet - easy to enter - easy to review.

Is there anything you don't like about your creation?

I used too many If(C2="","".....to check empty cell and to avoid formula error such as #div/0.
 
Last edited:
A second trick that I use is to shorten
= IF( [@Date]="", "", (1-[@[%Disc1]]) * [@LPumped1] * [@PerLCost1])
by using the fact that a date will be processed as TRUE and a missing date will be treated as FALSE. This allows you test for the active condition and leave the fallback to the second part of the statement
= IF( [@Date], (1-[@[%Disc1]]) * [@LPumped1] * [@PerLCost1], 0 )

Thanks, Peter.
This help!
 
Back
Top