In Feature Reports, is there a way to order a repeat by a number field that doesn't result in: 1, 10, 11, 2, 3, ..., 9
I found a way to trick this into working the way I want and how users expect it to work. But this solution is just silly:
It takes 21 rows to sort 1000 items.
Is there an easier way to do this?
Could you elaborate more on the workaround you found? I need to do something similar - users enter values for percent cover within a repeat in any order, but in the final report I need them printed in descending order. Could your workaround be used for that?
Sure! Hopefully this is easier to read:
For my first attempt, I used "orderByFields" as-is, with the result I am sure you are familiar with (e.g., 1,10,11,2,...,9).
For my second attempt, I combined "orderByFields" with an IF statement to filter out all of the rows I didn't want. While more tedious, this does give the expected result (e.g., 1,...,9,10,11)
In my case, I have a numeric field (rtv_num) that starts from 1 and counts up by 1 for every ever item in the repeat. This is what the orderByFields is based off of, and what I am using for my filter:
And of course, if there is nothing in a given number range, those rows are deleted from the table for a clean final appearance.
So, @abureaux to address your initial question, I tested this syntax with my survey, and it sorted as expected for numeric values (this was actually my first time trying this syntax, thanks for reminding me about it!)
Anyway, as you can see in this screenshot, they are definitely sorted descending by number, as intended.
In my case, I am sorted descending based on an integer type field. What field type is ${rtv_num} in your survey?
Ugh! So, it is an integer in the first repeat, but then converts to text in the second! As a result, half of my Feature Report was fine. This change was made after the survey was published, so the second field was missed since it is quite buried and only needed in the Feature Report.
Well, at least I now have a way to neatly organize "numbers as text" in the Feature Report!
Could you add another (hidden) field that would convert it *back* to an integer, to use for sorting?
Yep! That was my plan. Will be pushing the update this weekend, actually.