Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index

Here's a formula that works.  It's ugly, but it works.


The thing to do in a case like this is to break the problem down into sections. There are many ways to approach this specific question, but here's my thought process.

1. Go ahead and concatenate all the cells and worry later about whether or not they contain data. Insert semicolons between values.

2. Include a semicolon at the beginning and end of the string to accommodate the next two steps (in case the first or last cell is empty).

3.  Where two semicolons are consecutive, eliminate one of them.

4.  Eliminate the semicolons at the beginning and end of the string.

After that, I break the functions down to simplify construction of the monster.

A.  =MID([string],2,LEN([string]-2)
        This strips the beginning and ending semicolons.

B.  =SUBSTITUTE([string],";;",";")
This replaces every instance of two semicolons with a single one. Unfortunately, the function is not recursive, so if there are three in a row it will only make one replacement. This why the final formula has two instances of the SUBSTITUTE function.

C.  [string] is the concatenation of everything.

Hope this helps!


On 5/16/2013 07:23, Carl Paulsen wrote:
Hi Tom.

Well, not quite. In my particular case this formula worked. But with some off-list input from smarter brains than mine, I realize it wouldn't work under many situations.

It turns out the formula would need to change a bit, otherwise what I did would leave a trailing semi-colon where column X is blank. In fact, it's a tricky situation b/c a semi-colon is needed after U3 if U3 has a value AND any of the others has a value, otherwise not. Then, if V3 has a value and any of the other later cells has a value, there should be another semi-colon. Etc. etc. In the last case, a semi-colon should follow W3 only if there's a value in X3.

I've tried a bunch of formulas and the closest I've come is the following:


But that clearly doesn't work. Note I'm working in a test sheet and am using different cells. This formula leaves leading semi-colons under a number of situations and double semi-colons under others. I'm not entirely sure CASE would work any better here though.

Anyone want to help out, great. But it's a pretty specialized situation, so I understand if not.


On 5/16/13 3:02 AM, Tom Davies wrote:
Hi :)
WoooHooo!! Nicely done! :) Is this whole thread solved now? COngrats of so!
Regards from
Tom :)

    *From:* Carl Paulsen <>
    *Sent:* Thursday, 16 May 2013, 1:44
*Subject:* Re: [libreoffice-users] "Case" function equivalent in Calc

    At long last I got this to work.  Syntax is "ISBLANK" and not
- aaarrrrgggghhhh. My Filemaker days are getting in my way. Replace
    all "isempty" below with "ISBLANK" and it works perfectly now.


    On 5/15/13 6:38 PM, Carl Paulsen wrote:
    > So in the absence of a Case function, here's what I've done so
    far as
    > a calculated solution.  Note that the data I want to concatenate
    is in
    > cells U3, V3, W3, and X3.  In Y3, I put the following:
    > =U3 & IF(NOT(isempty(U3)),";","") & V3 &
    IF(NOT(isempty(V3)),";","") &
    > W3 & IF(NOT(isempty(W3)),";","") & X3
    > The idea is that I put together U3, a semicolon if U3 isn't
    empty (and
    > nothing if it is), V3 and a semicolon if V3 isn't empty, W3 and a
> semicolon if W3 isn't empty, and X3. If any of the cells is empty,
    > nothing will be added until the next cell that has data.
    > Unfortunately, I'm getting a #NAME? error.  I'm assuming some
    kind of
    > syntax error.  Any words of wisdom?
    > Thanks a ton all.
    > Carl
    > On 5/15/13 5:13 PM, Dan Lewis wrote:
    >> On 05/15/2013 04:16 PM, Carl Paulsen wrote:
>>> Anyone know if there is an equivalent to the Filemaker Pro "Case"
    >>> function?  It's kinda like the "IF" function but is simpler to
    >>> concatenate multiple conditions. It basically says If
    something is
    >>> true then do what is specified, if the next thing is, then do
    >>> if the next thing is true, do that, etc.
    >>> Here's what I need to do.  Take 4 columns and concatenate with a
    >>> semi-colon between the values, but not string together two
    >>> semi-colons consecutively.  Like:
    >>> Phone    Email    Mail -> Phone;Email;Mail
    >>> Phone                  Mail -> Phone;Mail
    >>>                            Mail -> Mail
    >>>              Email    Mail -> Email;Mail
    >>> So semi-colons only occur if there's a value present and not
    at all
    >>> if there's only one value present.
    >>> I hope that makes sense and displays correctly.
    >>> Carl
    >>      I just checked the available functions in Calc. The "Case"
    >> function does not appear among them. "Case When" is available
    in Base
    >> database queries though.
    >> --Dan

    Carl Paulsen

    8 Hamilton Street

    Dover, NH 03820

    (603) 749-2310

-- To unsubscribe e-mail to:
    Posting guidelines + more:
    List archive:
    All messages sent to this list will be publicly archived and
    cannot be deleted

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.