Solved

Excel: how to use if- and statements to calculate fee

Posted on 2014-03-31
5
208 Views
Last Modified: 2014-03-31
I need to use logic statements to determine fee for a service depending on age and gender

I have the following source table:

                                  M        F
Less than 18 years             100      80
18 to 35                              200      170
More than 35 years             300      270      


where gender will be in column B, age in column C, and fee amount in column D
so i basically need a function that'll read something like:

if  (B1 = "F") then
    if (C1  < 18) then 80
    else if (C1>=18 or C1 <=35) then 170
    else 270
else if (B1 = "M") then
    if (C1  < 18) then 100
    else if (C1>=18 or C1 <=35) then 200
    else 300



please assist?
0
Comment
Question by:badtz7229
  • 3
  • 2
5 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39968358
Try this:
=IF(B1="F", (IF(C1<18, 80, IF(OR(C1>=18, C1<=35), 170, 270))), IF(B1="M", IF(C1<18, 100, IF(OR(C1>=18, C1<=35), 200, 300))))

Open in new window

HTH,
Dan
0
 

Author Comment

by:badtz7229
ID: 39968364
Dan,
It works ok, but does not satisfy condition of genders where age is > 35
0
 

Author Closing Comment

by:badtz7229
ID: 39968381
This worked. thanks so much for your help.
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39968379
That's because I replicated your algorithm that has a flaw :)
=IF(B1="F", (IF(C1<18, 80, IF(AND(C1>=18, C1<=35), 170, 270))), IF(B1="M", IF(C1<18, 100, IF(AND(C1>=18, C1<=35), 200, 300))))

Open in new window

You need an AND to test for between...
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39968395
Glad I could help!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now