Ron Posted March 30, 2005 Share Posted March 30, 2005 Hi Guys, I have a calculation which displays the company name. The calculation will look if the Company_name field is empty. if it is I would like to concatenate the first_name and last_name in its place. Thank you for your help Link to comment Share on other sites More sharing options...
Robert Schaub Posted March 30, 2005 Share Posted March 30, 2005 Code: cCompanyName = Case(IsEmpty(CompanyName);first_name & " " & last_name;CompanyName) Link to comment Share on other sites More sharing options...
CobaltSky Posted March 31, 2005 Share Posted March 31, 2005 Robert is right on the nail (Hi Chopper!). But Ron, what if the first_name or last_name (or both) fields are also empty? Link to comment Share on other sites More sharing options...
Maarten Witberg Posted March 31, 2005 Share Posted March 31, 2005 Hi Ray, I can't imagine that you would not have thought of this one: Code: Case( not IsEmpty(company_name); company_name; Case( not IsEmpty(Trim(first_name & " " & last_name)); Trim(first_name&" "&last_name); "person and organization unknown" )) But I say stick with Chopper's, that one's simple.... kjoe Link to comment Share on other sites More sharing options...
CobaltSky Posted March 31, 2005 Share Posted March 31, 2005 Hi Kjoe, Well, were I proposing that, I would likely cast it along the lines of: Code: Case( IsEmpty(company_name & first_name & last_name); "-unknown-"; IsEmpty(company_name); Trim(first_name & " " & last_name); company_name ) - however what's at issue here is what Ron actually *wants* to happen in the event that all three fields are blank. I'm not sure if he's considered that case - but if so, he's not indicated how he would want to deal with it. It may be that if all three fields are empty then the preferred result would be a null. It may be that the preferred result would be a default value (such as your formula or mine above would return). Or it may be that the preferred value would be a reference to some other field. But my point (and my concern here) was that Chopper's formula would not return any of these, but instead would return a lone space. It may be of no consequence, but I figure it does no harm to ask the question... Link to comment Share on other sites More sharing options...
Maarten Witberg Posted March 31, 2005 Share Posted March 31, 2005 re: it does no harm to ask the question It sure doesn't! kjoe Link to comment Share on other sites More sharing options...
comment Posted March 31, 2005 Share Posted March 31, 2005 If we are striving for perfection, IsEmpty() is redundant here. Case( Company_name ; Company_name ; first_name & " " & last_name ) will do the job. Link to comment Share on other sites More sharing options...
CobaltSky Posted March 31, 2005 Share Posted March 31, 2005 Hello Comment, I am afraid you are mistaken. IsEmpty( ) is not redundant. In the expression you have suggested, the company name will only be returned if the company name resolves as a non-zero integer. This is because FileMaker evaluates boolean logic numerically with zero and empty (including non-numeric) values evaluating as false. Since the company name will frequently be text-only and will therefore not provide a net numeric value, the test you are suggesting will fail in most cases. Among the few exceptions to this would be company names starting with 't' or 'y' which, in FileMaker 6 and earlier will evaluate as Yes/True. But in FileMaker 7 even these exceptions will not apply (the behaviour of Booleans in this respect has changed in v7). Link to comment Share on other sites More sharing options...
comment Posted March 31, 2005 Share Posted March 31, 2005 Oops. You are right, of course. I was thinking of something else. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.