Good Morning,
I have a Survey123 form for a Tree Inventory survey which contains a repeat (${#trees_repeat}). Within the repeat, I have a field that lists the species of the tree ( ${tree} ) and the assessed condition of the tree ( ${condition} ), populated from a list with values like "poor", "fair", etc.
My feature report template includes a table listing every individual tree by ${tree_ID} that is working well:

but I also need to create a summarized section with a count of condition ratings, grouped by species. Here is an example from the reports that are arborist are currently making manually, which is the goal I'm aiming for:

And this is as close as I've been able to get thus far (orderBy and the TreeCount for each species working as I want it to, but I'm not sure how to summarize the condition counts for each species in the table):

The code I'm using in the feature report table to print out the repeat records sorted by species is:
${#trees_repeat | stats:"count,objectid,TreeCount":"tree": "" | where:"1=1" | orderByFields:"tree ASC" }${tree}
And the whole table (including the counts by conditions for all the records in the repeats, not just the species)
Species | Count | Excellent | Poor |
${#trees_repeat | stats:"count,objectid,TreeCount":"tree": "" | where:"1=1" | orderByFields:"tree ASC" }${tree} | ${TreeCount} | ${trees_repeat | where:"condition = 'excellent' " | stats:"count,objectid"} | ${trees_repeat | where:"condition = 'fair' " | stats:"count,objectid"}${/} |
If what I'm after is possible, I assume that I need to add in these other summaries to the code in the first column using multiple outStatistics parameters, but I haven't been able to figure out how to include a filter or where clause for just those specific outputs/results. I was thinking something like this (which doesn't work):
${#trees_repeat | stats:"count,objectid,TreeCount;count,condition='poor',PoorCount":"tree": "" | where:"1=1" | orderByFields:"tree ASC" }
Any help would be greatly appreciated. I've been using the help doc here as a reference, but haven't been able to make it work for my purposes - Report queries—ArcGIS Survey123 | Documentation
Thanks