Select to view content in your preferred language

Survey123 Feature Report Conditional Aggregate Not Formatting with Decimals

176
2
02-21-2025 09:17 AM
RebekahCooper
New Contributor

We are developing a summary report for a client where they need to submit the sum of Estimated Costs (Value field in the feature service) for certain permit types to the county every month. 

They want there to be a $ before the sum, so we put that in front of the field, however, the report lists all permit types available in their survey, so there will be months where some permit types were not applied for. Because of that, when a permit is not applied for in a given month, there's a floating $ in the report which they wanted to not happen.

So, we developed an aggregate script where the $ will only show up if there are permits, aka the TotalValue is greater than 0. This is working with no issues:

${#FeatureService | stats:"sum,Value,TotalValue" | where:"Type='BUILDING' AND Class='Commercial_Acc_Structure'"} ${if TotalValue > 0}$${TotalValue}${/}${/}

Additionally, though, they need to show 2 decimal places. This formatting is not working. We did not get errors when pushing it to Survey123, but it did not generate to 2 decimals. This is how the above script was modified:

${#FeatureService | stats:"sum,Value,TotalValue" | where:"Type='BUILDING' AND Class='Commercial_Acc_Structure'"} ${if TotalValue > 0}$${TotalValue | format: "#,###.##"}${/}${/}

0 Kudos
2 Replies
GlenterpriseUK
Esri Contributor

Hi @RebekahCooper,

Have you tried adding a round expression so that it displays the decimals?

Please check the documentation https://doc.arcgis.com/en/survey123/browser/analyze-results/featurereporttemplates.htm#:~:text=For%2...

Regards,

Glen

0 Kudos
RebekahCooper
New Contributor

Thank you! Classic case of overthinking! While I didn't use round because our values are currency, and we want to force double decimals i.e. .00 and .50, so instead I used the ${decimal1 | toFixed:3} expression!