Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro Cycling Through Records

Hi, I'm using QlikView 9.0 to present the findings of a questionnaire, I'd like to have one sheet that allows the user to cycle through questions.

I've tried using a slider but since the sections each have a different number of questions it doesn't really work since the slidder doesn't appear to change to limit to the number of questions.

Is it possible to use macro/buttons to allow records to be cycled by changing the selection using code?

Cheers

Steve

5 Replies
Not applicable
Author

Hi Steve,

Can you please post the qvw for the reference. May be variables can solve your problem.

Thanks & Best Regards,

Kuldeep Tak

Not applicable
Author

Just a quick guess at what you want to do...

Create an Input Box, then add a new variable, say varQnum. This allows the user to set the required question. In the load script you can set this variable to 1 using

LET varQnum = 1;

Create macros for scrolling the questions

sub Qup
varQnum = varQnum + 1
end sub

sub Qdown
varQnum = varQnum - 1
end sub

Create two buttons, labelled 'Next' and 'Previous' and assign the relevant macro to each.

In the table that displays the answers, a Chart - Straight table, create a calculated dimension, and label it as 'Question Number', with the formula

if ( Question = '$(varQnum)', Question )

then tick the 'Suppress when value is null' box (note there is no 'false' section in the if statement)

The variable now holds the required question number, and is changed by the input box or macros. The Chart then compares the question records and if the Question field matches the variable it displays the Question number, if it does not match the value is null, and this is suppressed.

Not applicable
Author

Thanks for that, got it working with a straight table. Is there anyway of changing a selection based on the value of a variable within the script?

Cheers

Steve

Not applicable
Author

Use the same technique as above, with an 'if ( )' statement and 'Suppress nulls'.

Variables are applicable everywhere in QV, so if you create one in the script, you can use it in charts, etc.

Not applicable
Author

Another thought... if you make the question number a list box, the up and down cursor keys scroll through the values. Then you don't need a macro or variables.