Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Randomly Generating Data

Hi everyone.

I have a request to attach a field to a table based on a random selection from a previously loaded table.

I have a set of Facts that are devoid of the dimension Market.

I have a second set of Facts that get concatenated to the previous one which does include Market.

My task is to apply that Market from the second set of Facts randomly to the first set, so as to be able to view the filter across all Facts Even though the Market is completely unrelated between the two data sets at the current time, it will be available in the future, and this is for an example of the future functionality.

So, I have to attach the Market to the entire data set, but I do not have a key to map to. I just need to randomly pick a Market from the second data set for each row in the first.

Any idea how I can do this?

Thanks in advance!

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

First load the set with the Market values and then try something like this in the second load statement:

FieldValue('Market', Ceil(Rand()*FieldValueCount('Market'))) as Market


talk is cheap, supply exceeds demand
Not applicable
Author

Hmmm...

Not sure I'm doing this correctly.

When referencing 'Market' in this expression, it needs to already exist in the Fact table, correct?

When I try to load it and reference it from another table it returns field not found.

But, if i use this expression after the Fact tables are already concatenated, wouldn't it be adding the null field value to the generated list of possible Markets?

Not applicable
Author

Nevermind! Figured it out.

This method works perfect.

THANKS!!!