Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to select expression from cyclic expression group

Hi All,

I'm looking for a macro solution for selecting an expression from a cyclic expression group.

For various reasons i will not go into I have very little flexibility with regards to alternatives that involve creating variables, modifying the load script etc. I'm pretty much 'forced' to use a macro approach with the chart objects in the application.

I'm looking for something along the lines of (for Dimension groups)

...SET Group = doc.GetGroup("Product/Team")

...Group.cycle 1

Below is the direction I've been heading towards after researching this topic on the community.

...SET expr = chartProp.Expressions.Item(0).Item(0).Data.ExpressionData

   ........expr.CycleGroup = 1

    ...... chartObj.SetProperties chartProp

Can anyone point out the correct syntax for this? (assuming there is a macro solution to this problem....)

Thanks in advance.

4 Replies
marcus_sommer

To look for the syntax and various examples you could use the APIGuide.qvw: Re: Where to find latest API guide.

Whereby I'm not sure if there are not other easier solutions for this - maybe by not using expression groups and controlling the visibility with conditions (on selections or variables).

- Marcus

Gysbert_Wassenaar

If you have enough access to the document to mess around with macros then you have enough access to create variables. Can you explain what you need to do?

If you're trying to create a mechanism that allows a user to select an expression then there are far easier ways. And you're not forced to change your data model. One variable will be enough to give a user the option to select between expressions and have a chart display the chosen expression.


talk is cheap, supply exceeds demand
Not applicable
Author

Apologies for the late response.

I'm familiar with the API guide, and I already have variables in place for the 'Conditional' property of each expression. The app. was developed by a third party, my task is to create an 'export to PPT macro'.

A specific example:

I have a pie chart with one cyclic dimension group and one cyclic expression group. I need to

select a specific dimension and a specific expression in said chart and then export an image to the PPT slide.

Below is how I solved the dimension selection problem, and ideally I'd like to have a similar solution to the expression selection problem.

'---- set cyclic dimension group (cdGRP_1) to show 'FLD_1'--------------------

    Set group = ActiveDocument.GetGroup("cdGRP_1")

    set gp = group.GetProperties

    set vars = gp.FieldDefs

    myFld = "FLD_1"

        FOR i = 0 TO vars.Count-1

            set activeFld = group.GetActiveField

                   

            IF activeFld.Name <> myFld THEN

                group.Cycle 1

            END IF

        NEXT

    Doc.GetApplication.WaitForIdle   

At the moment the work around I have for the cyclic expression selection problem is :

1. Disable the expressions in the existing expression group.

2. Recreate a temporary new expression (identical to one of the disabled ones)

3. Export the chart image

4. Kill the temporary expression

5. Enable the old expressions from step #1.

Gysbert_Wassenaar

If you're using variables for the Conditional property of the expressions, then you don't need an expression group. Just enable the expression you want to show and hide the others by changing the Conditional properties using the variables.


talk is cheap, supply exceeds demand