Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to create a PivotTable through a macro. I need to use a macro because :
- The dimensions are variables
- The number of dimensions is variable
- The number of rows or columns is variable
- A dimension can be hide with a clic
I can do it except the last point (when the selection changes, I delete all the dimensions and then I add the dimensions I need). I looked into the API but I didn't find the right method. I tried
ActiveDocument.GetSheetObject("CH02").GetProperties.Dimensions(0).AttributeExpressions.ShowValueExp.Definition.v = "{condition}"
but it doesn't work.
Thank you for your help !
Enzo
Hello,
I think it can help. I tried several things and I find a function that doesn't appear in API but it works.
To fill the field Enable Conditional you need to use the attribute EnableCondition.Type and EnableCondtion.Expression.
EnableCondition is a bit like Show, it means EnableCondition.Type can be 0, 1 or 2. I didn't find any diffrences between the values 1 and 0, but the value 2 activate the Enable Conditional field.
The expression of the condition can be set with EnableCondition.Expression and can be see in the user interface.
You can attach a condition to a dimension thanks to this.
Here is an exemple :
set obj = ActiveDocument.GetSheetObject("CH08")
set objProp = obj.GetProperties
set variable = objProp.Dimensions(0).EnableCondition
variable.Type = 2
variable.Expression = {condition}
obj.SetProperties objProp
Enzo,
Try the following link..will give information about hiding dimension using macro.
http://www.citagus.com/citagus/blog/hiding-dimensions-in-qlikview-pivot-table/
and this thread
Regards.sivaThanks siva for your help.
It's a good idea and it will probably work (I can't test right now).
I wonder if it is possible to fill the field of conditional display for a dimension with macro (I use QV in french so I don't know the exact word for this field in english). Do you know something about it ?
Enzo
This can be done using varables to show or hide Dimensions and Expressions
Thanks Alan for answering.
I know you can hide or show Dimensions with variables, but I wonder how to set up which variable to use for which dimension with a macro.
For example, I want to add a dimension called Test and I want this dimension to be displayed if the variable show = 1 (the variable already exists). I can add the dimension with .AddDimension "Test" but I don't know how to manage the conditional display with macro.
Hello,
I think it can help. I tried several things and I find a function that doesn't appear in API but it works.
To fill the field Enable Conditional you need to use the attribute EnableCondition.Type and EnableCondtion.Expression.
EnableCondition is a bit like Show, it means EnableCondition.Type can be 0, 1 or 2. I didn't find any diffrences between the values 1 and 0, but the value 2 activate the Enable Conditional field.
The expression of the condition can be set with EnableCondition.Expression and can be see in the user interface.
You can attach a condition to a dimension thanks to this.
Here is an exemple :
set obj = ActiveDocument.GetSheetObject("CH08")
set objProp = obj.GetProperties
set variable = objProp.Dimensions(0).EnableCondition
variable.Type = 2
variable.Expression = {condition}
obj.SetProperties objProp