Search code examples
crystal-reportscrystal-reports-formulas

If statement and split function


My memo line that looks something like this:

Return: #999 100.00\NSF|Balance=$242.00. Available Balance=$50.00`

or

Return: #888 45.90\WD REST.

I need it to return everything before the | if there is one, or the whole memo line if there isn't a |. Right now I have two formulas that give everything before the | or nothing if there isn't a |

memo1: left({table.memo},instr(table.memo},"|"))

memo2: replace({@Memo1},"|"," ")

How can I configure this such that if a | is present, return @Memo2, else return {table.memo}?


Solution

  • If I understand correctly, just make one more formula like this:

    IF instr({table.memo},"|")>0
    THEN {@Memo2}
    ELSE {table.memo}
    

    This displays one formula or the other based on the presence of that vertical line character.