Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
blaise
Partner - Specialist
Partner - Specialist

rank() in ascending order

Hello Qv'ers

I have a very simple problem (and most likely a simple solution...)

In a rather complex calculation i need to check the ranking of a date, and if the ranking is below a specific no use that as the expressions result.

The expression is used in a Boxplot but I've tried to simplify it by testing on a very simple straight table.

I have the following data;

text,no

ett,1

tva,2

tre,3

fyra,4

fem,5

sex,6

I want to show a ranking of the field "no" in a straight table where 1 has the ranking of 1 and 6 has a ranking of 6 (ie rank in ascending order).

I've tried every parameter setting in the rank function, all of them results in the same result (ie 1 gets ranking of 6 and so on)

I've tried to upload ademo application but received a aspx error but i've tried with the expression (aggr(rank(no,3,1),text) in a straight table with text and no as dimension without luck (as well as aggr(rank(no,1),text))

The expression for the boxplot is (if you're interested);


<div>max( {$<Date= {">=$(vDateStart)<=$(vDateStop)"}>} </div><div>aggr(</div><div>If((PlannedNo-round(PlannedNo*0.1))<rank(RankDate,3,1),</div><div>interval(RankDate - Date,'DD'))</div><div>,Country,City)</div><div>)</div>


This works good if all Country's has a RankDate but i want to see the max interval for the Cities that has a ranking that is below 10 % of "PlannedNo".

"PlannedNo" is f.ex. 100 for a Country with 100 cities. I want so show the interval(RankDate - Date,'DD') for the country with the 10th lowest RankDate. RankDate is a field in the DB that gets populated once the cities has been ranked.

If all Cities has a RankDate, the if() statement will return a number smaller than the rank() function and the max interval function will be returned - but if not 90 % of the cities has a RankDate the if statement will never be true.

Br Blaise

1 Reply
pover
Luminary Alumni
Luminary Alumni

To change the order of the rank try something like the following:

rank(max(total no) - no)

Regards.