Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello every one...
I was trying to create a button in Qlikview which show & hide values on data point in line chart using macro.
I have used below macro script in my approach...
sub ShowHide
set myobj = ActiveDocument.GetSheetObject("CH85")
set v = ActiveDocument.GetVariable("VClikCount1") '' 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
'enable second expression
set expr1 = prop.Expressions.Item(1).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
v.setContent "0",true
end if
myobj.SetProperties prop
End Sub
Limitation of this macro is it needs 2 expression in one chart which conditionaly enable & disable using the macro.
Can anyone suggest me the same by using only one expression in chart.
Thanks
Here you go, then. If you have 20 charts, you'll probably want to make CH01 a parameter so that you don't have to duplicate this logic for each.
sub showvalue
set myobj = ActiveDocument.GetSheetObject("CH01")
set v = ActiveDocument.GetVariable("Hide") '' first create a varible using setting
prop = myobj.GetProperties
set expr = prop.Expressions.Item(0).Item(0).Data.ExpressionVisual
if v.getcontent.String=0 then
expr.NumbersOnBars = true
v.setContent "1",true
else
expr.NumbersOnBars = false
v.setContent "0",true
end if
myobj.SetProperties prop
end sub
Hi,
Let me explain what you can do with an example.
You have chart where you want to show sum and count conditionally. Meaning on clicking on button it should show sum and again clicking on button chart should show count.
Create a varibale which have values 0 and 1. Say varibale1 = 0 for sum and varibale1 =1 for count
Create another varibale which will store the expression. like
Varibale2 = if(Variable1 =0,'SUM(Sales)','Count(Sales)') Make sure that you include the expression in quote.
Create a button to toggle the value of Varibale1
i.e In Action -> Add-> External -> Set variable -> Variable Name - Variable1
-> Value - > =if(Variable1=0,1,0)
Also Check the Exmaple
Hope this will help you
Regards,
Kaushik Solanki
Consider creating two charts and a checkbox (list box, single value, windows checkboxes selection style). If the checkbox is checked (selected count = 1), show one chart. If not, show the other. No macros, no actions. It barely counts as dual maintenance since you just build one chart from the other any time you make changes. See attached.
John - Thank you very much. I am in need of same.
Cheers - DV
Thank you every one for your inputs...
Thank you John...
In my applicaion there are total 20 Bar charts...
So creating two chart i.e. one for show values & other for hide values is not feasible solution..
Because it will increase my numbers of chart in application...
I am attaching one demo application in which I am doing the same using macro...
but the problem is that I want to do the same using one expression...can it be possible...
please suggest me the solution
Thanks again...
Here you go, then. If you have 20 charts, you'll probably want to make CH01 a parameter so that you don't have to duplicate this logic for each.
sub showvalue
set myobj = ActiveDocument.GetSheetObject("CH01")
set v = ActiveDocument.GetVariable("Hide") '' first create a varible using setting
prop = myobj.GetProperties
set expr = prop.Expressions.Item(0).Item(0).Data.ExpressionVisual
if v.getcontent.String=0 then
expr.NumbersOnBars = true
v.setContent "1",true
else
expr.NumbersOnBars = false
v.setContent "0",true
end if
myobj.SetProperties prop
end sub