Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show you how to use shortcut menus in the Access run-time environment.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

820 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