Select to view content in your preferred language

Survey123 report template: inserting a zero when number question type is blank

334
2
Jump to solution
06-24-2024 05:19 PM
CharlottePeters95540
Occasional Contributor

I'm posting a solution to an issue I had with inserting a zero when an integer or decimal question type was blank in a report template. Hope this saves someone hours of troubleshooting, despair, and frustration. rptnull.jpg

The following expression worked for me on a feature report for a survey that had nested repeats (e.g. Project main-->Site repeat-->Feature repeat). In my case, the report ran calculations on all the features within a single project. If the question is blank a zero is inserted; otherwise, a calculated value is returned.

Syntax: 

${#FeatureRepeat | stats:"sum,Question name to sum,Variable name to hold sum result"}${Variable name+0 | format:"#,##0"}${/} 

Example:

${#rptFeature | stats:"sum,RoadMilesDecomm,RdMi"}${RdMi+0 | format:"#,##0"}${/}

The variable name can be whatever you want it to be. The number format is optional. 

 

 

0 Kudos
1 Solution

Accepted Solutions
CharlottePeters95540
Occasional Contributor

I'm posting a solution to an issue I had with inserting a zero when an integer or decimal question type was blank in a report template. Hope this saves someone hours of troubleshooting, despair, and frustration. 

CharlottePeters95540_0-1719602590032.jpeg

 

The following expression worked for me on a feature report for a survey that had nested repeats (e.g. Project main-->Site repeat-->Feature repeat). In my case, the report ran calculations on all the features within a single project. If the question is blank a zero is inserted; otherwise, a calculated value is returned.

Syntax: 

${#FeatureRepeat | stats:"sum,Question name to sum,Variable name to hold sum result"}${Variable name+0 | format:"#,##0"}${/} 

Example:

${#rptFeature | stats:"sum,RoadMilesDecomm,RdMi"}${RdMi+0 | format:"#,##0"}${/}

The variable name can be whatever you want it to be. The number format is optional. 

View solution in original post

0 Kudos
2 Replies
ChristopherCounsell
MVP Regular Contributor

Thanks for sharing. Can you please post your solution and mark it as the answer?

0 Kudos
CharlottePeters95540
Occasional Contributor

I'm posting a solution to an issue I had with inserting a zero when an integer or decimal question type was blank in a report template. Hope this saves someone hours of troubleshooting, despair, and frustration. 

CharlottePeters95540_0-1719602590032.jpeg

 

The following expression worked for me on a feature report for a survey that had nested repeats (e.g. Project main-->Site repeat-->Feature repeat). In my case, the report ran calculations on all the features within a single project. If the question is blank a zero is inserted; otherwise, a calculated value is returned.

Syntax: 

${#FeatureRepeat | stats:"sum,Question name to sum,Variable name to hold sum result"}${Variable name+0 | format:"#,##0"}${/} 

Example:

${#rptFeature | stats:"sum,RoadMilesDecomm,RdMi"}${RdMi+0 | format:"#,##0"}${/}

The variable name can be whatever you want it to be. The number format is optional. 

0 Kudos