Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
jblomqvist
Specialist
Specialist

How can I make this Rand() script work? Trying to assign a Sales Person based on a random ID?

Hi all,

I have the following piece of script:

Emp:

LOAD Floor(SalesID) as SalesID, Name INLINE [

    SalesID, Name

    1, Julie

    2, John

    3, David

    4, David R

    5, Teresa,

    0, Michael

];

Data:

LOAD

ApplyMap('Emp', RandNum,'Missing') as SalesPerson,

*;

LOAD

     Floor(Rand() * 5) as RandNum,

     <other data>

FROM datafile.xls;

The output is blank for SalesPerson column:

Any idea how to fix this?

The point is to assign a random sales person based on the RandNum field.

1 Solution

Accepted Solutions
Kushal_Chawda

Mapping key word missing

Emp:

mapping LOAD Floor(SalesID) as SalesID, Name INLINE [

    SalesID, Name

    1, Julie

    2, John

    3, David

    4, David R

    5, Teresa,

    0, Michael

];

View solution in original post

4 Replies
Kushal_Chawda

Mapping key word missing

Emp:

mapping LOAD Floor(SalesID) as SalesID, Name INLINE [

    SalesID, Name

    1, Julie

    2, John

    3, David

    4, David R

    5, Teresa,

    0, Michael

];

sunny_talwar

Did you miss the Mapping keyword?

Emp:

MAPPING

LOAD Floor(SalesID) as SalesID, Name INLINE [

    SalesID, Name

    1, Julie

    2, John

    3, David

    4, David R

    5, Teresa,

    0, Michael

];

jblomqvist
Specialist
Specialist
Author

Of course, such a silly mistake thank you

swuehl
MVP
MVP

And maybe use

   Floor(Rand() * 6) as RandNum,


so that Teresa gets a chance to get picked, too.