Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Save $600 on Qlik Connect registration! Sign up by Dec. 6 to get an extra $100 off with code CYBERSAVE: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
koushik_btech20
Creator
Creator

Macro for Enabling or Disabling Expression dynamically

Hi Everyone,

I have a category or component table which I have to extract from DB so the data which will consist uder Category field will be dynamic . Now for each category I am creating expression and label.So there are already 2 expression present in the pivot chart which will be by default and now based on the Category or component field selection we have to enable or disable expression and have to show selected component label for the corresponding expression. I was trying that problem through macro. May be it is possible through macro . Could anyone check and let me help.Please check the attached application.

Regards,

Koushik

3 Replies
Siva_Sankar
Master II
Master II

Koushik,

Below is the code

sub ends

set myobj = ActiveDocument.GetSheetObject("CH01")

set v = ActiveDocument.GetVariable("VClikCount") '' first create a varible using setting

Cnt= v.getcontent.String

prop = myobj.GetProperties

if Cnt=0 then

  set expr = prop.Expressions.Item(0).Item(0).Data.ExpressionData

  expr.Enable = true                      'enable first expression

  set expr1 = prop.Expressions.Item(1).Item(0).Data.ExpressionData

  expr1.Enable = true    'enable second expression

  set expr1 = prop.Expressions.Item(2).Item(0).Data.ExpressionData

  expr1.Enable = false    'disable second expression

  v.setContent "1",true

else

  set expr = prop.Expressions.Item(0).Item(0).Data.ExpressionData

  expr.Enable = false                'disable first expression

  set expr1 = prop.Expressions.Item(1).Item(0).Data.ExpressionData

  expr1.Enable = true    'enable second expression

  set expr1 = prop.Expressions.Item(2).Item(0).Data.ExpressionData

  expr1.Enable = true  'enable second expression

  v.setContent "0",true

end if

myobj.SetProperties prop

end sub

tresesco
MVP
MVP

Not sure if I understood right. You may try like shown here : Adhoc reporting in Qlikview

koushik_btech20
Creator
Creator
Author

But the selection data is not static so I cant do this in the way we do in Adhoc reporting.