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: 
wnorwood
Contributor III
Contributor III

Set Expression Conditional Show/Hide in Macro

Hello,

I have a macro that builds a couple of charts dynamically.  I have a table that tells it which dimensions and expressions to display in the chart based on a selection from a list box.  But, I have one set of expressions for one of the list box options needs to display only when the max of the values in not 0.  I have been trying to find vb script that can either find the max of the value or set the presention condition expression text.  But, I haven't had any luck.

Does anyone know how to do either of these? Or, does anyone have any other suggestions?  I am at a complete loss.

Thanks.

4 Replies
Anonymous
Not applicable

I would try to set the condition on the list box:

=max(FieldA)<>0

But you could create a variable and set it to calculate the max(FieldA) and then check the value of the variable in your macro.

For example:
v_MaxTest   set to =max(FieldA)


vb code:
set v = ActiveDocument.Variables("v_MaxTest")
msgbox(v.GetContent.String)

Phil

wnorwood
Contributor III
Contributor III
Author

This is great! But, I have about 25 expressions that I need to test.  Is there a way to set the variable in the vb script?  Or can that only be done in QV variable settings? I am already looping through a list of expressions, so it would be exceptionally nice to be able to add this test in there.

Thanks again!!

Anonymous
Not applicable

Sure. You can set a variable using the following code:
set v = ActiveDocument.Variables("v_MaxTestB")
v.SetContent "=max(b)",true

--- end of code
Do you know about the APIguide.qvw? You can find this on the download site. Search for "APIguide"
I do not see a version 11 there yet, but I think most of the code will still work fine. This has examples for whatever you need to do. Of course, if you can avoid using macros, that would be best. But sometimes you have no choice.
-Phil

wnorwood
Contributor III
Contributor III
Author

I found the app and will definitely check it out.  Thanks.