Solved

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

Posted on 2014-03-31
5
210 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

805 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