Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to build a straight table that contains a pseudo-random sample of data. I have two input boxes, one that allows the user to enter the total number of records the straight table should contain, and another that I'm calling the "Random Factor". Basically I want to spin through the data model and write every Nth record in my straight table until I've reached a specific number of records. I can limit the total number of rows easily enough, but I can't figure out a way to dynamically allow the user to chose a "Random Factor" and write only every Nth record to the straight table. Actually, I the input box allows them to enter the Random Factor, I just don't know how to make the straight table use it. Any ideas?
Thanks,
Bret
Figured it out. I had to add a row number field to the table in the load and use that row number in the Modula function rather than the RowNo() reserved word. I've attached the app for your review. Thanks for your help. Bret
Not sure if I understood your requirement.
Using modulo function mod(x1, x2) and rownumber you should be able to filter every nth row.
like in expression
= if(mod(ROWNUMBERFIELD, 10) = 1, ROWNUMBERFIELD, 0)
should output every 10th row number.
Stefan
P.S: This is of course not a random row selection
P.P.S:
In your straight table, put all fields you want to show as dimension and above expression as expression. QV will not show every row with expression evaluates to zero, if in tab presentation, don't show zero values (or similar wording) is activated (that's standard).
P.S. added by swuehl
swuehl,
Thanks for taking time to look into my issue. The Mod function gets me close, but I still can't make the table row display or not based on the value of the expression. If I was doing this in the load script, it would work, but I'm on the front end trying to limit the rows in a table.
Bret
Hi Bret,
In front end, use a straight table with your fields you want to show as
dimension, one expression as above. Rows with value zero should Not be shown
by default.
You can then hide the expression column If you want.
Am 27.07.2011 00:53 schrieb "Bret Meissner" <
qliktech@sgaur.hosted.jivesoftware.com>:
the discussion
"Re: Displaying every Nth row in a chart."
To view the discussion, visit:
http://community.qlik.com/message/136121#136121
Hi,
See if the attached sample can help you.
Cheers.
Hi BlackRockS, Thanks for taking the time to look into this as well. Your solution is close but not quite. Let's say I have a chart that would normally render 100 rows. I want my user to be able to enter a 4 (for example) in an input box, and have every 4th row display in the table, for a total of 25 rows. I've been able to get to where you are, the problem is I can't make the chart only render the 25 rows I want. They could concieveably enter a five in which case I'd want every 5th row to display a total of 20 rows. Bret
That doesn't work. I've attached my app. Bret
Cant you just give each row a rowno() during load, and then just have a dimension of if(rowno = mod(x), rowno) that you hide in the presentation tab?
Figured it out. I had to add a row number field to the table in the load and use that row number in the Modula function rather than the RowNo() reserved word. I've attached the app for your review. Thanks for your help. Bret
Hi,
I have done some changes to your data loading script and created another table. Hope this is what you wanted. Please check the load syntax and the expression on the new chart object I have added.
Best Regards,
Sajeevan