Formatting combined variables

Hello!

Is there a way to dynamically insert an "enter" when stringing variables together?

lifetime ascvd kf blurb
&10-year ascvd kf blurb
&cac kf blurb
&lipid kf blurb

These blurbs can contain text (lifetime ascvd kf blurb="Your risk is high") or be blank (lifetime ascvd kf blurb="").

Right now my output looks like:
lifetime ascvd kf blurb``10-year ascvd kf blurb``cac kf blurb``lipid kf blurb

I'd like it to look like:
lifetime ascvd kf blurb
10-year ascvd kf blurb
cac kf blurb
lipid kf blurb

Bonus points if we can not add a return if the blurb is blank (ie if cac kf blurb=""):
lifetime ascvd kf blurb
10-year ascvd kf blurb
lipid kf blurb

Hey @Abby_Buccino,
Yes, join with "\n", which represents a new line.
In this example, I create a list of the values and filter out empty ones. Then I join with a \n

{formtext:name=lifetime ascvd kf blurb;default=lifetime blurb}
{formtext:name=10-year ascvd kf blurb;default=10-year blurb}
{formtext:name=cac kf blurb;default=CAC blurb}
{formtext:name=lipid kf blurb;default=Lipid blurb}
{list=[`lifetime ascvd kf blurb`,`10-year ascvd kf blurb`,`cac kf blurb`,`lipid kf blurb`]}
{=join(filter(list,x->x<>""),"\n")}

3 Likes

This is exactly what I needed. Thank you for your quick response. I can't wait to apply it to this and many other snippets :slight_smile: