Select to view content in your preferred language

How to add Apostrophe to Calculation field in Survey123?

2109
3
Jump to solution
05-12-2021 06:45 AM
Labels (1)
by Anonymous User
Not applicable

I used a custom URL to pass coordinates in DMS.  The Coordinates are saved without the degrees symbol, quotes and apostrophe:

40 18  54.12345 N

I want to use the calculation field to add in the degrees symbol, double and single quotes to make it look like this:

40° 18' 54.12345" N

 

To do this, I planned to use the "substr" function combined with the "concat" function.  The problem is that I can't get it to add in the single apostrophe.  So how do I add an apostrophe (single quote)?

 

concat((subtra(${DMSLat},0,2})), '° ',(subtra(${DMSLat},3,5)), '' ',(subtra(${DMSLat},6,12)),'" N')

 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

I assume just a typo in your formula since you said substr but wrote subtra.  Also you have several syntax errors in the expression

concat((subtra(${DMSLat},0,2})), '° ',(subtra(${DMSLat},3,5)), '' ',(subtra(${DMSLat},6,12)),'" N')

But when I fixed that the issue seems to be you can have a single quote inside of a double quote but not a double quote inside of a single quote.  Then it seems that also cannot mix and match quotes styles on 1 line, even though I thought I had done this in the past.  I also removed the concat since it seemed weird.

I tried escape with double quotes and \ but nothing worked.  Someone may know how to escape a double quote?

Best I could do was simulate a double with two singles which looks ok.  Actually this may even be technically correct to use two singles?  Like inches and feet I think its two singles not a double.

DougBrowning_0-1620832021584.png

You must split it into two fields the combine the fields, no idea why but prob cant mix and match text qualifiers.

Create a text field to hold the last part  -> field testing2 with a calc of '"'' N"  this is two singles inside of a pair of doubles.

Then add that field onto the end of the rest

substr(${temptest},0,2) + '° ' + substr(${temptest},3,5) + "' " + substr(${temptest},6,12) + ${testing2}

Hope that helps.  

 

 

View solution in original post

0 Kudos
3 Replies
AndrewBowne
Frequent Contributor

did you try adding two single apostrophe's?

 

concat((subtra(${DMSLat},0,2})), '° ',(subtra(${DMSLat},3,5)), ''' ',(subtra(${DMSLat},6,12)),'" N')

or, try adding a character code:

concat((subtra(${DMSLat},0,2})), '° ',(subtra(${DMSLat},3,5)), 'CHAR(39) ',(subtra(${DMSLat},6,12)),'" N')
0 Kudos
DougBrowning
MVP Esteemed Contributor

I assume just a typo in your formula since you said substr but wrote subtra.  Also you have several syntax errors in the expression

concat((subtra(${DMSLat},0,2})), '° ',(subtra(${DMSLat},3,5)), '' ',(subtra(${DMSLat},6,12)),'" N')

But when I fixed that the issue seems to be you can have a single quote inside of a double quote but not a double quote inside of a single quote.  Then it seems that also cannot mix and match quotes styles on 1 line, even though I thought I had done this in the past.  I also removed the concat since it seemed weird.

I tried escape with double quotes and \ but nothing worked.  Someone may know how to escape a double quote?

Best I could do was simulate a double with two singles which looks ok.  Actually this may even be technically correct to use two singles?  Like inches and feet I think its two singles not a double.

DougBrowning_0-1620832021584.png

You must split it into two fields the combine the fields, no idea why but prob cant mix and match text qualifiers.

Create a text field to hold the last part  -> field testing2 with a calc of '"'' N"  this is two singles inside of a pair of doubles.

Then add that field onto the end of the rest

substr(${temptest},0,2) + '° ' + substr(${temptest},3,5) + "' " + substr(${temptest},6,12) + ${testing2}

Hope that helps.  

 

 

0 Kudos
by Anonymous User
Not applicable

Man that’s obnoxious.  The only reason why the coordinates are in the format without the degrees and quotes is because they wouldn’t pass from my layer to the Survey123 form via a custom URL. So I removed them assuming it wouldn’t be difficult to add them back. Kind of annoyed I have to add another field just to get the formatting.  

Thanks though, I don’t know what or if any other solutions are out there. 

0 Kudos