Expression Assistance - Concatenation with IF statement

I am trying to craft a virtual column to show some information about a given patient's dialysis schedule in one line. I started with this expression, which does not work:

AND(
CONCATENATE([Status],"|",[Modality],"|",[Dialysis Location]),
IF([Modality]="ICHD",CONCATENATE("|",[ICHD Schedule],"|",[ICHD Shift]),CONCATENATE("")
))

its the IF part that is breaking things but i am having trouble figuring out how to get this syntax right.
looks pretty straight forward, i want the column to be text and read like

[STATUS] | [Modality] | [Dialysis Location]

and stop there if [Modality] is not equal to ICHD, but if it is ICHD, then continue like:

[STATUS] | [Modality] | [Dialysis Location] | [ICHD Schedule] | [ICHD Shift]

i have tired a few different things but i suspect my nesting is all wrong. The error message says that something has an invalid expression (obviously since it doesnt work) that is expecting a yes/no condition. That takes me back to the IF() function, i believe, which looks like it has a yes/no result in that does the value of [Modality] equal ICHD, yes or no.

What am i missing?

thank you


0 3 29
3 REPLIES 3

Well, you are clearly using AND() wrong man, I just noticed it and I'm sure you just didn't, those things happend.

Use this instead:

CONCATENATE(
  [Status], "|",
  [Modality], "|",
  [Dialysis Location],
  IF(
    [Modality]="ICHD",
    CONCATENATE(
      "|",[ICHD Schedule],
      "|",[ICHD Shift]),
      ""
  )
)

Or, if you need some space between the data and "|":

CONCATENATE(
  [Status], " | ",
  [Modality], " | ",
  [Dialysis Location],
  IF(
    [Modality]="ICHD",
    CONCATENATE(
      " | ",[ICHD Schedule],
      " | ",[ICHD Shift]),
      ""
  )
)

 

i could have sworn i tried something like that, but after a few tries, it all starts to run together ๐Ÿ˜‚

I guess i was using the AND statement to hopefully add the rest "if" this, but as you said, wrong approach. seems with every little bit of progress, a new challenge arises, but i am thankful to have folks to help me learn this. It'll continue to sink in slowly but surely.

thank you


@mykrobinson wrote:

i am thankful to have folks to help me learn this


๐Ÿ˜‰

Top Labels in this Space