6 Replies Latest reply on Aug 2, 2017 8:01 AM by philmodjunk

# auto enter data depending on age and gender

Hi everyone,

I am looking to auto-enter a value according to a customer date of birth and gender.

I want to be able to calculate a discount percentage

For example if the customer is over 18 years old then the discount is 5%  if over 65 it would be 25%.

But it should also calculate the months and days. If the baby is only 6 days old then the discount is 90% and if 8 month 80%.

Then I would also be able to give a different discount if the person is a boy or a girl. If 12 years old and girl its 10% and if boy 9%,

The % will never change so I can set up a calculation but I am not sure how to start.

• ###### 1. Re: auto enter data depending on age and gender

First you need to calculate the age, e.g.:

Next you'd use a Case function, e.g.:

Case(

ageYrs > 65 ; .25 ;

ageYrs > 18 ; .05 ;

ageMonths = 8 ; .8 ;

ageDays <= 6 ; .9

)

1 of 1 people found this helpful
• ###### 2. Re: auto enter data depending on age and gender

@Tom Fitch is on the right track here with a case statement but it does not tackle all the issues.

According to your description a 66 year old man is potentially eligible for the following discounts:

5% discount for 18+

25% for over 65

9% for boy.

What do you expect the discount for this person to be?

Once you have the requirements clearly defined only then can you ( or us herein ) write a calculation that gives you the correct results every time.

1 of 1 people found this helpful
• ###### 3. Re: auto enter data depending on age and gender

thanks for helping,

No, if 65 years old and man it is fixed to 25% and if woman 26%. It doesn't add and will never change.

I tried

Full Age

FullAge (calculation, text result) =

GetAsText ( Year ( Get ( CurrentDate ) )  - Year ( Birthdate ) - If ( Get ( CurrentDate ) <  Date ( Month ( Birthdate ) ; Day ( Birthdate ) ; Year ( Get ( CurrentDate ) ) ) ; 1 ; 0 ) ) & " Years, " & GetAsText ( Mod ( Month ( Get ( CurrentDate ) ) - Month ( Birthdate ) + 12 - If ( Day ( Get ( CurrentDate ) ) < Day ( Birthdate ) ; 1 ; 0 ) ; 12 ) ) & " Months, " & GetAsText ( Day ( Get ( CurrentDate ) ) - Day ( Birthdate )  + If ( Day ( Get ( CurrentDate ) )  ≥ Day ( Birthdate ); 0 ; If ( Day ( Get ( CurrentDate ) - Day ( Get ( CurrentDate ) ) ) < Day ( Birthdate ) ; Day ( Birthdate ) ; Day ( Get ( CurrentDate ) - Day ( Get ( CurrentDate ) ) ) ) ) ) & " Days "

Now I don't seem to be able to use it for calculation. Because this is text result I presume ?

I can't yet figure out how it works but this doesn't give any result:

Year ( Get ( CurrentDate ) ) - Year ( Date of Birth )- If ( Get ( CurrentDate ) < Date ( Month ( Date of Birth ) ; Day ( Date of Birth ) ; Year ( Get ( CurrentDate ) ) ); 1 ; 0 )

Is there anything wrong with this formula ?

• ###### 4. Re: auto enter data depending on age and gender

"It doesn't add and will never change."

I put that in the category of "famous last words". ;-)

You really can't predict what outside forces might force you to change this. In my part of the world, you might even get sued for "gender bias" and have to change this.

So a table based system of values from which you then look up this data might be a better option as it can make it possible for your system to adapt to change via data entry instead of needing a developer to redefine a case function.

1 of 1 people found this helpful
• ###### 5. Re: auto enter data depending on age and gender

Hi;

Hehe, I see the filemaker community also has its sense of humour

But ok; let me be more clear, I just gave this example of discounts because I thaught it would be easier to understand for people. But in fact I am doing a Laboratory results sheet.

The Normal Range of the results depend on your age and your gender.

For exemple if you are 2 years to 12 years old male, the blood count (WBC) range will be ''5.7-9.9'' but if female   ''5.4-9.7'':   But if you are a baby male 15 days to 31 days the range should be ''8.9-16.7''

This is why I said it would never change because these values are fixed.

So the first part would be to display the ''Range Field'' that displays the information according to his age and gender.

The second part is when I enter the data in the ''Result Field'' it should compare to the ''Range'' and if it is in the range it should display in the ''Comment field'' = "Normal" or if higher than the range "High" or lower "Low".

So i set up a layout where I select the ''Patient Name"", and it shows its birthday already. I also calculate the age the results being text ''6 days" or "11 months"" or "35 years"

The rest I don't know.

Hope this makes this clearer to understand.

Thanks again for taking your time to look at this.

• ###### 6. Re: auto enter data depending on age and gender

That definitely reduces the odds that you'll need to make a change by a large margin, but:

"This is why I said it would never change because these values are fixed."

Still might not be the case. I'm not saying that you should switch to a table, this is a judgement call for you to make, but these "fixed" values look to this layman like data that might change in the future if further research indicates that new norms are more appropriate. Treating data as a constant when it's not a constant is a frequent design shortfall found in database systems so it's a soap box that I frequently preach from, whether it applies here or not is up to you as there does come a point where the added complexity needed to make a feature flexible isn't really justified due to the long odds against it actually changing--especially when FileMaker is a tool that enables us to make rapid design changes to ongoing solutions (unless you have distributed 20,000 copies of your solution that all need an update of course...)

PS. nearly always, using an analogy instead of the actual details of your problem don't really help us to help you. Instead, you run the risk of getting help that works well with your analogy and poorly if at all with the real case. There's some pretty smart, educated people offering you free help in the posts that preceded mine, they can handle the real thing.

1 of 1 people found this helpful