Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
js_giraldo
New Contributor

Random numbers without repeating

Hi, guys. I hope you can help me

I need exactly to assign a number to the value of the field Team Name between 1 and 8, but not repeat a already number assigned

Teams:

LOAD * INLINE [

TeamName

Mexico

Brazil

Colombia

France

USA

Argentina

Peru

Spain];

Example Result:

example.PNG

Thank's

5 Replies
balabhaskarqlik
Honored Contributor

Re: Random numbers without repeating

May be:

In Expressions: Rank(Only(TeamName),7) - Label - Rank

In Script:

Teams:

LOAD * INLINE [

TeamName

Mexico

Brazil

Colombia

France

USA

Argentina

Peru

Spain];

FinalTable:

LOAD *,

  If(TeamName <> Previous('TeamName'), RangeSum(Peek('Rank'), 1), 1) as Rank

Resident Table

Order By TeamName desc;

DROP Table Teams;

ogautier62
Valued Contributor II

Re: Random numbers without repeating

Hi

take a look at function Autonumber() it's made for this :

Autonumber(TeamName)

regards

MVP
MVP

Re: Random numbers without repeating

Only thing is, it would not be random, but sequential.

ogautier62
Valued Contributor II

Re: Random numbers without repeating

you are right,

so :

LOAD  *, rand() as rand FROM    'your table'

 

load *, autonumber(rand) as nb resident 'your table' order by rand;

 

that changes on each load

MVP
MVP

Re: Random numbers without repeating

This is a way to get a randomly picked list of teams:

2018-07-26 12_11_42-Microsoft Edge.png