Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

grenwick
New Contributor III

Create variable for ranked position

I have the following table:

LOAD * INLINE [

Name, Value

A, 10

B, 5

C, 3

D, 4

E, 4

F, 5

G, 7

];

I would like to create a variable that returns the name of the 4th in the list when ranked.

It can't be done on load script.

Thanks for your help

Tags (2)
1 Solution

Accepted Solutions
grenwick
New Contributor III

Re: Create variable for ranked position

I got it,

=only

        (

        if (

            Aggr(

                Rank(Sum(Value), 4, 1), [Name]) = 4,  [Name]

            )

        )

using the option 4 in the rank function was key due to the values been the same.

4 = Lowest rank on first row, then incremented by one for each row.

4 Replies
anbu1984
Honored Contributor III

Re: Create variable for ranked position

Is Value itself rank or you want to create rank based on value?

MVP
MVP

Re: Create variable for ranked position

=FirstSortedValue(Name, Value, 4)

Re: Create variable for ranked position

Hi

Try something like this

In your example, there is no 4th rank. So I changed little bit.

Load  * INLINE [
Name, Value
A, 10
B, 5
C, 3
D, 4
E, 4
F, 6
G, 7
]

= MaxString(Aggr(If(Rank(Sum(Value)) = 4,Name), Name))

grenwick
New Contributor III

Re: Create variable for ranked position

I got it,

=only

        (

        if (

            Aggr(

                Rank(Sum(Value), 4, 1), [Name]) = 4,  [Name]

            )

        )

using the option 4 in the rank function was key due to the values been the same.

4 = Lowest rank on first row, then incremented by one for each row.

Community Browser