Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Adding new Dimension from selected values in Listbox

Hi guys,

I have a 2 list boxes and a bar graph... I want to select a value in Listbox1 and the selected value will be the dimension of my graph... and then when I select another value from Listbox2 it should be added after the first value/dimension of my graph. But I can't make this work.

Any suggestions for this? Thanks!

8 Replies
Not applicable
Author

There is a file in the 'Share qlikviews' section about just that!

Enjoy

http://community.qlik.com/media/p/91101.aspx

Not applicable
Author

Hi Jesper...

wow! thanks for the link.. I saw the macro...

Since I'm not changing the Expressions. I removed the code for adding Expressions.. my problem is the chart.AddDimesions seems not working...

or should I put a code somthing like this:

set p = chart.GetProperties

set

exps = p.Expressions

exps = p.Expressions exps = p.Expressions

set

expItem = exps.Item(i).Item(0).Data.ExpressionVisual



chart.SetProperties p

what is the counterpart of ExpressionVisual for Dimension?

THANKS! 😄

Not applicable
Author

I never tried the macro myself, I just wanted to let you know that somebody had looked into it 🙂

Cant help you any further than the posted link, sorry

Good luck

johnw
Champion III
Champion III

Nadsky, responding to your private message. As I recall, the approach I've used for dynamic reporting is very similar to Nick's approach. So I'll start by just posting my own template, in case that answers your questions in some way. If you're not adding and removing expressions, then it looks like you can strip my macro down to the below code:

sub rebuild()
ActiveDocument.GetApplication.WaitForIdle 'wait for QlikView to finish before modifying report
set selectedDimensions = ActiveDocument.getField("Dimensions").getSelectedValues
selectedDimensionMax = selectedDimensions.Count - 1
if selectedDimensionMax >= 0 then 'bypass if nothing is selected
set chart = ActiveDocument.getSheetObject("CH01")
chartDimensionMax = chart.GetColumnCount - 1
for i = chartDimensionMax to 0 step -1 'remove existing dimensions
chart.removeDimension i
next
for j = 0 to selectedDimensionMax 'add selected dimensions
chart.addDimension selectedDimensions.Item(j).Text
next
end if
end sub

johnw
Champion III
Champion III

If your chart is supposed to always have two dimensions, though, and only WHAT those dimensions are is dynamic, I wouldn't use the macro approach. I'd use two cyclic groups. So your first cyclic group would contain all the fields allowed as the first dimension. Your second cyclic group would contain all the fields allowed as the second dimension. Those two groups would be your two dimensions. You'd be selecting from groups instead of list boxes, but it's pretty much the same idea, and avoids macro code (you want to avoid macro code when you can).

Not applicable
Author

I tried the sample macro code you gave me... The code is working, it deletes the existing Dimensions.. retrieves the selectedDimensions (checked by msgbox(selectedDimensions.Item(j).text)) but my chart don't display ANY dimensions.

Is there something I need to update? like chart.Properties or something?

Thanks

Not applicable
Author

Check attachment, I've commented all expressions' code. It works for dimensions only now.

Not applicable
Author

Hi,

i have same situation here too. i need to add selected expressions to the table ( either straight table or pivot table).

by default some expressions will be there in the table. but user needs extra expressions that will be available in the list box, so that he will be able to add to the table on the fly if he needs to.

can you provide me a macro code to do that with an example, as im new to this environment.

that will be a great help for me.