Page 1 of 1
combine calculation flds
Posted: Thu Jun 02, 2005 4:51 pm
by Smzemke_(Guest)
If I have multiple calcuation fields that only contain strings of data, is it possible to combine them all into a new calculation field?____example:____Calculation fields:__ Field F1 contains "strawberries"__ Field F2 contains "blueberries"__ Field F3 contains "rasberries"____Is it possible for me to combine these into a field and call the field "Berries", and have each of the above fields in this new one?____Does that make sense?____I want to do it for using iif statements, i.e. IIf A=1,Berries=F1____Thanks
=> RE: combine calculation flds
Posted: Thu Jun 02, 2005 6:14 pm
by Alan_Klein
You are on the right track. For example:____Name the field "Berries", with the expression:__IIF(A=1, F1 + " " + F2, F2)____In this example, if A=1 then Berries will be "strawberries blueberries", otherwise it will just be "blueberries". You can put punctuation along with the space in the quotation marks in the middle, if needed.____You can nest IIF^s as well. For example:____IIF(A=1, F1, IIF(A=2, F1 + " " + F2, IIF(A=3, F1 + " " + F2 + " " + F3,"")))____In this example:__If A=1, Berries will be "strawberries";__If A=2, Berries will be "strawberries blueberries"__If A=3, Berries will be "strawberries blueberries rasberries"____In no case will raspberries be spelled correctly!
==> RE: combine calculation flds
Posted: Thu Jun 02, 2005 6:15 pm
by Alan_Klein
That line with the smiley should read:____IIF(A=1, F1, IIF(A=2, F1 + " " + F2, IIF(A=3, F1 + " " + F2 + " " + F3,""))
===> RE: combine calculation flds
Posted: Thu Jun 02, 2005 6:17 pm
by Alan_Klein
Once again, without feeling:____IIF(A=1, F1, IIF(A=2, F1 + " " + F2, IIF(A=3, F1 + " " + F2 + " " + F3,"" ) ) )
====> RE: combine calculation flds
Posted: Fri Jun 03, 2005 7:49 am
by Smzemke_(Guest)
I^ll try this out - Thanks for your suggestion!
=====> RE: combine calculation flds
Posted: Fri Jun 03, 2005 9:50 am
by Rick_Johnson_(Guest)
Another way to do this, if there are not too many different berries, is to use the CASE statement. Much like the IFF, it might be a tad easier to write and more importantly, when you go back a year from now to modify, might be more readable. ____CASE(BerryCode,"1","strawberries","2","strawberries blueberries","3","strawberries blueberries rasberries", " ")______In this situation, if the BerryCode is not 1,2,3 you get the default " " (space).________________
======> RE: combine calculation flds
Posted: Thu Jun 09, 2005 9:27 am
by Smzemke_(Guest)
Thank you - I^ll try that too!