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: 
qlik_venu
Creator
Creator

Qlikview Macro - to add dimensions dynamically

Hi All,

I need a help on the following macro.

I am using a FIELD which has the following values like

Region,

Year,

Department

There are around 50 dimensions like this. User will be selecting the required dimensions for a crosstab report themselves. So I want the selected values in the Field to be sent to a macro and then the dimensions have to added to the Pivot table.

I have written the following script. but I am unable to make the Field selections to be passed to an array variable and then add it to the Pivot table using a loop. Need your help pls.

I am not able to pass the strVariable to the Array function.Getting error in the msgbox function. If this works i wil then add the loop to add the fields one by one below.

SUB add_dimension

Set chart =ActiveDocument.GetSheetObject("CH07")
SET vb=ActiveDocument.Variables("V_dim_fields")
strVariable= vb.GetContent.String
a=Array(strVariable)
msgbox(a(1))

a.chart.AddDimension "COUNTRY"
'Adding the single dimension "Country" works fine.
End Sub

Thanks,

Venu

1 Reply
Gysbert_Wassenaar

If you're using QV11 I'd use conditional expressions instead like in this example. But if you feel you need to use a macro to do this look at the example here.


talk is cheap, supply exceeds demand