Chalkster Posted March 27, 2005 Posted March 27, 2005 I have written a calculation and I think there should be a simpler version but i cant work it out I have twelve fields where a user should enter either a numeric value or a percentage. The fields together comprise a calculation to add a profit margin to airfares stored at buying price in the database. A user may specify a fixed price markup or a percentage depending on passneger tyrpe , one way or return and wholesale or retail. I use a single calculated check field to check each filed in sequence and return a value to show the first field with invalid data... so I use a case statement. What i have written for field one is Case (not( (Right ( Ag_AD_RT;1 ) ="%" ) and( ((Length ( GetAsNumber ( Ag_AD_RT ) ))+1) = (Length ( Ag_AD_RT ))) )and Length ( GetAsNumber ( Ag_AD_RT ) )<>Length ( Ag_AD_RT );1; not( (Right ( Ag_CH_RT;1 ) ="%" ) and( ((Length ( GetAsNumber ( Ag_CH_RT ) ))+1) = (Length ( Ag_CH_RT ))) )and Length ( GetAsNumber ( Ag_CH_RT ) )<>Length ( Ag_CH_RT );2; ....etc etc and then repeated to include all fields one at a time with a final value if all data is valid... ie failed all tests to find incorrect data This works... but am i being overcomplicated?
Recommended Posts
This topic is 7249 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now