Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
There is an old discussion related to this in the archive. Unfortunately, the attachment is not available and the proposed solution in the text does not seem to work. Does anyone know how to accomplish the following.
I am trying to add the following calculated dimension to a chart via a macro:
=if(payment_terms='PP',1,null())
The macro doesn't stop on the .adddimension statement:
chart.addDimension "if(payment_terms='PP',1,null())"
but it does not add a dimension to the chart at all. I have tried putting 'PP' into a variable, putting CHR() functions in place of the single quotes, etc.
Thank you in advance...I have been tearing my hair out!
I'm having nothing but trouble with those calculated dimensions. I did come up with a workaround (I think) that uses a dollar sign expansion and your Month_View variable.
You are already populating that variable with the correct first dimension. If we set the first dimension to "=$(Month_View)" and set the second dimension to your if formula, it seems to work.
I took copies of each chart with the proper first dimension and this macro switches them correctly.
Sue,
In fact, I am using AddDimension for the calculated dimensions in a production application, and it does work. You problem is apparently somewhere else. First of all, add the "=" beforethe "if". The definition of the calculated dimension in the macro must be exactly the same as if you created it manually.
I've tried it both with / without the equal sign. No luck. It just seems to ignore the calculated dimension and doesn't add it at all. I'm going to try uploading a sample of this. Would you mind taking a look at it or trying it on your machine?
Could you show us the entire macro contents?
I had a similar problem in the past. I whipped up a quick macro that uses AddDimension. Here it is:
SUB Test
set chart = ActiveDocument.GetSheetObject("CH53")
chart.AddDimension "FIELD"
END SUB
The problem is that the dimension will be added, but will not appear on the chart. If I open the Properties window, it is in the Dimension list. When I click Ok, the chart will refresh and I see the Dimension.
If I do the GetProperties/SetProperties thing around the AddDimension line, nothing will be added to the chart.
I thought I discussed this problem in another thread, so I'm going to take a look and see if there was a good solution. EDIT: This may be the thread I was thinking of: http://community.qlik.com/forums/t/16449.aspx. The user was having problems with an AddDimension in a long macro and doing the AddDimension in a separate subroutine (or I think simply rearranging the macro) seemed to fix the issue.
See attached stripped-down copy ... I took out the load script, so just don't reload 🙂
I'm having nothing but trouble with those calculated dimensions. I did come up with a workaround (I think) that uses a dollar sign expansion and your Month_View variable.
You are already populating that variable with the correct first dimension. If we set the first dimension to "=$(Month_View)" and set the second dimension to your if formula, it seems to work.
I took copies of each chart with the proper first dimension and this macro switches them correctly.
Aha. I like it. It simplifies the code a lot and gets rid of a good bit of "clutter". Thank you!
NMiller & Sallen - I understand that this thread is very old. Although I ran into same problem and I got it working now. Many thanks to both of you
Cheers - DV