can you check this & let me know if it's a solution 4 ur problem ...
if not let me know where i'm getting wrong
solution.qvw 148.8 K
That's indeed a creative solution. If you would rather do with code and use a single chart, here's how you can do so:Setup a trigger on the DEPT field (Settings | Document Properties | Triggers, Field Event Triggers, select Dept, add an Action for "OnSelect". Action should be External / Run Macro, then edit the module and create the following macro sub:Sub SetTrendVisibilityByDept
' get value of field DEPT
Set valDept = ActiveDocument.Fields("Dept").GetSelectedValues
Set obj = ActiveDocument.GetSheetObject("CH01")
Set objProp = obj.GetProperties
Set objExpr = objProp.Expressions.Item(0).Item(0).Data.ExpressionVisual
' toggle invisible property of chart expression
' based on value of DEPT field selection
if valDept.Count = 1 then
objExpr.Invisible = False
objExpr.Invisible = True
End SubFinally, be sure to set the name of the sub as the Action for the triggger (SetTrendVisibilityByDept).This macro assumes your chart object is CH01, and that the first dimension is to be changed (the first .Item(0) sub is the dimension). Also, the bars appear only if you select ONE department (thus the code: If valDept.Count = 1). If you want the bars on any number of Depts, change to If valDept.Count > 1. When the user clears the selections, the value for valDept.Count will = 0.I 've attached a sample of your solution with this code in place. Make a select for Dept. and you see the bars, clear it and they go away.
The first Item(n) is the collection representing the Expressions, and it's 0-based (so Item(0) is the first expression). If you were looking instead at Dimensions, then it would be the collection of dimensions (and in this case, you would reference the .ExpressionData object instead of .ExpressionVisual.
As for the apparent collection under this collection (thus the next .Item(0)), I have not found documentation or been able to resolve why that's a collection. I examined the docs I could find, and exported the chart to XML in order to study, but it appears it's always just ONE member of this sub-collection (whether it be ExpressionData or ExpressionVisual). Perhaps QlikView is storing other members in this collection, but it seems all of the common properties are exposed under this first member.
The API Guide for QlikView may be downloaded from their site (Downloads section), which provides a lot of help on the object model. I'd like to see more, but it's a great place to start.