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

Macro/Set Analysis Help

Hi guys,

I have a macro which selects all the values in a field. I was wondering is it possible to create a macro whereby when I click on a tab the macro runs and only affects one object in this tab.

Would set analysis work in this case, i.e. putting set analysis in all the other objects apart from the one which I want the macro to run in?

I think that this may cause problems as when the macro runs it reduces the number of selections available in the list boxes present in the tab and set analysis can't be implemented in a list box.

If anyone has some tips or better ideas feel free to post.

I appreciate your help.

5 Replies
Not applicable
Author

What is the object? Is it a chart? If so, I would agree with Set Analysis.

I would use:

Sum({<FIELD = {$(vSelections)}>} Sales)

Where vSelections is a variable containing the values to be selected.

Are you still going to be using the macro to make selections for the other tabs? I don't think you can use Set Analysis or even detach a list box. If you want the selections in all of the other tabs to not affect the other items in this special tab, then that may be difficult without some creative loading.

Not applicable
Author

Yes it is a chart. My option was slightly different than yours but probably less efficient. I was going to implement the macro across the sheet and then put set analysis on everything but the chart in question so they would be unaffected.

My selections are a set of numbers,so would i simply list them in the variable so that vSelection = (1.1, 1.2, 1.3, 1.4) etc? I tried doing this but it didn't seem to work.

Just to add to this, is there a way where you do not have to list all the individual options within the variable but instead create a variable which selects all values within the field in a ompler code form?

Not applicable
Author

your definition of vSelection looks correct, except you don't want the parenthesis. If you use a dollar sign expansion with a variable, you can put the expression in a chart expression without a label and when the chart is rendered the variable will be evaluated and you should see what QlikView is using.

If you want to choose every value for a field, you can use the asterisk.

Sum({1<FIELD={*}>} Sales)


That will ignore selections and pull every value of FIELD. I'm not sure that will give you what you want though, because in that expression, the Set Analysis is doing nothing. Also, if you don't have any selections in FIELD, QlikView will automatically select everything. I think I am missing something. Do you want all selections to be respected except the selections on FIELD where you want to show every value?

Not applicable
Author

I'll try and explain better. I have an expression

count (Response)
for a chart.

However, I would like this chart to have another field called LTONum fully selected. Using the variable I was unable to do this as it gave me errors so my code was getting very long like this

Count( {$< LTONum = {"1.1","1.2","1.3","1.4","1.5","1.6","1.7","2.1","3.1","3.7"} >} Response)
This is the shortened version!

Is there a better and easier way to do this? Using the variable creator i have created one like above without the paranthesis, simply vSelection as the variable name and the inpute as 1.1, 1.2, 1.3 and so on and it isn't working.

Not applicable
Author

If you use double-quotes in the explicit expression, your variable also needs the double-quotes.

It looks like you want to respect all selections, but ignore the selections on LOTNum and instead, select every value. Have you tried this:

Count( {$< LTONum = >} Response)


That seems to work in my testing. All other selections are respected, but it basically ignores selections on that field and lets everything through.