As you can see in the manual for the inter record function RowNo(), sorting straight tables by expression is not allowed when you use a chart inter record functions. Therefore you can not arrange the sorting directly by arranging the sort order in the chart's expressions.
The easiest workaround for this scenario is that you simply sort the chart by the first dimension instead. The trick is then to sort the dimension by an expression. Assuming that you want to sort the count() first and then the sum(), you would set up the sort expression as below to simply make the count() result the most significant part;
=count(F1)*1000000 + sum(F4)
NOTE: The multiplier needs to be larger than the largest sum for this to work properly
TestRanking.qvw 150.8 K