Instead of using a conditional statement, here is a better alternative to hiding the rows for the riders who haven't led any rides.
1. In the view "Ride Leader Number of Rides List", I added a unique ID to each table row, based on the rider post's ID, so that each one can be targeted individually using the CSS code:
( screenshot: hidden link )
<tr id="rider-[wpv-post-id]">
2. In the child view "Ride Leader Number of Rides List Count Field", I included the following CSS code, that hides the table row, only if it doesn't return any results.
( screenshot: hidden link )
<style type="text/css"> tr#rider-[wpv-attribute name="targetrider"] {display:none;} </style>
Notes:
a). The CSS code is added within the "wpv-no-items-found" tags, which is why it is only included for the child view's loop when it doesn't return any result.
b). The CSS code uses the shortcode "wpv-attribute" to get the ID of the rider post that is being passed by the parent view through the shortcode attribute "targetrider".
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-attribute
As for sorting the results by the number of rides led, it is not possible through the parent view's sorting/ordering settings or query, because the number of rides is calculated by the child view and not the parent view.
To achieve this, you'll need to use some custom script, that orders/sorts the table on the front end, once it has been generated.
Here are some of the example scripts that you can use:
hidden link
hidden link
You'll find some useful pointers on this topic in this other support forum thread:
https://toolset.com/forums/topic/sorting-nested-tables/page/2/
For more personalized assistance around custom code/scripts, you can hire a professional from our list of recommended contractors:
https://toolset.com/contractors/