combine calculation flds
-
- Posts: 41
- Joined: Tue Oct 10, 2017 12:44 pm
combine calculation flds
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
-
- Posts: 68
- Joined: Tue Oct 10, 2017 12:44 pm
=> RE: combine calculation flds
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!
-
- Posts: 68
- Joined: Tue Oct 10, 2017 12:44 pm
==> RE: combine calculation flds
That line with the smiley should read:____IIF(A=1, F1, IIF(A=2, F1 + " " + F2, IIF(A=3, F1 + " " + F2 + " " + F3,""))
-
- Posts: 68
- Joined: Tue Oct 10, 2017 12:44 pm
===> RE: combine calculation flds
Once again, without feeling:____IIF(A=1, F1, IIF(A=2, F1 + " " + F2, IIF(A=3, F1 + " " + F2 + " " + F3,"" ) ) )
-
- Posts: 41
- Joined: Tue Oct 10, 2017 12:44 pm
====> RE: combine calculation flds
I^ll try this out - Thanks for your suggestion!
-
- Posts: 35
- Joined: Tue Oct 10, 2017 12:44 pm
=====> RE: combine calculation flds
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).________________
-
- Posts: 41
- Joined: Tue Oct 10, 2017 12:44 pm
======> RE: combine calculation flds
Thank you - I^ll try that too!