Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
jblomqvist
Contributor II

Is it possible to do randomise the field to Order By?

Hi all,

Let's say I have the following table:

LOAD
OrderID,

OrderDate,

CustomerID,

ProductID

Value

Resident <table>

Order By OrderDate

Is it possible in the above to randomly swap the field to order by?

Say it's OrderDate but in the next reload it can randomly order by CustomerID or ProductID.

How is it possible to do this? Any ideas?

1 Solution

Accepted Solutions

Re: Is it possible to do randomise the field to Order By?

May be like this (Have not tested this, but I think it should work):

LET vRand = Ceil(Rand() * 3);

LET vField = Pick($(vRand), 'OrderDate', 'CustomerID' , 'ProductID');

LOAD
OrderID,

OrderDate,

CustomerID,

ProductID

Value

Resident <table>

Order By $(vField);

1 Reply

Re: Is it possible to do randomise the field to Order By?

May be like this (Have not tested this, but I think it should work):

LET vRand = Ceil(Rand() * 3);

LET vField = Pick($(vRand), 'OrderDate', 'CustomerID' , 'ProductID');

LOAD
OrderID,

OrderDate,

CustomerID,

ProductID

Value

Resident <table>

Order By $(vField);

Community Browser