Concatenating values of various fields and adding newline

I want to concatenate values of various fields and want to display in one field. So in calculation parameter I am adding concat(fields1,field2, field3).
On device I want it to be displayed as :

So how can I add newline character in the concat string in calculation ?

Hello @Sonali,

If this is just for displaying purpose, you probably might wanna consider calling desired variables/values directly in line with the note text like this:

type is note
label: this is a summary of my previous three variables
V1: ${field1}
V2: ${field2}
V3: ${field3}
Vn: ${fieldn}
add more text as you want .

By the way, alt+enter (pc) or option+enter(mac) is the trick to break a lines without leaving the cell in focus

You probably could achieve the same with concat() or join() and use any separator desired in your calculations. Though I doubt this custom concat/join will later be useful any other way than displaying ... hence suggesting you write it directly in the note or question label

Hoping it helps,

Jules R

1 Like

What seperator we can use with concat() ?

I think what @jules_rugwiro is suggesting here is that you avoid concat() and join() - @jules_rugwiro can you provide an example sheet with your suggestion?

Hello @KeynesYouDigIt and @Sonali,

That was exactly my point. I am still trying to imagine the final use of the data with line-feeds in them (if the suggested solution won't work for you and still opt for calculated field) @Sonali please elaborate further on the final expected output.

Looking online, the &#10; and codepoints-to-string(10) happen to be the line-break in XPath, but I am not sure how that is translated into XLSForm syntax (alternatively, you can manually modify the xml of your form to use <bind calculate="concat( /data/field1 ,'&#10;', /data/field2 ,'&#10;', /data/field3 )" nodeset="/data/join" readonly="1" type="string"/>

In any case, if the purpose is to display some sort of summary, use the shared form for a working example

See this sample BreakLine_Test_202110_jr.xlsx (10.4 KB)
It looks like this:

Jules R

1 Like