Solved

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

Posted on 2014-03-31
5
213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 35

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 35

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 35

Expert Comment

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

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

717 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