Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Create table based on Fields selected in List Box

Hello all,

I swear that I had seen this as a post sometime ago, but I could not find it with Search (my lack of being able to come up with a key word, I suppose). Does anyone have any macros that will allow a user to make field selections in a list box and then have a table created with those selected field names? I am looking to get rid of the constant requirement of calls to add a certain field to a report. We use the plugin, so it must be able to work in both the developer and plugin environment.

Thanks,

JS

21 Replies
johnw
Champion III
Champion III


Christian77 wrote: The thing is that neither mine nor yours work in QV 10.
What do we do?




To make sure we're seeing the same problem, if any dimensions are selected, it comes up with the big X and the little button to try again.

Interestingly, if I open up the properties, make NO changes, then click "OK", the chart then comes up fine.

It wouldn't surprise me if there's something that's changed in how macros are supposed to add dimensions, so some property is a little off, and then just opening up properties and saying OK is somehow flipping it to an allowed value of something.

The API guide isn't any help. The examples seem to indicate that there's nothing special or new in regard to adding dimensions. And even gutting the macro and table (one expression, removing and readding a hardcoded dimension) causes the failure.

So I'm going to call it a bug, and it seems like a very basic bug with adding dimensions using a macro. If I come up with a workaround, I'll post it. Unless it's fixed in SR2, I'll need to come up with a workaround, because the current plan is to officially upgrade to version 10 once SR2 comes out.

Is anyone successfully adding dimensions using a macro in version 10 SR1?

johnw
Champion III
Champion III


spencern wrote:Could you use a bookmark to save the selections of a table? Then the user wouldn't have make any other selections.


How would bookmarks allow us to dynamically add and remove dimensions and expressions from a table?

johnw
Champion III
Champion III

OK, this is the simplest demonstration of the problem I could think of. I have only a single field, MyField. I have a straight table with no dimension and no expression that doesn't suppress zero values. I have this macro tied to a button.

sub test()
ActiveDocument.getSheetObject("CH01").addDimension "MyField"
end sub

In version 9 SR6, if you click on the button, the chart appears.

In version 10 SR1, if you click on the button, the chart doesn't appear. If you open the properties of the chart, you can see that the macro DID work, in that it added MyField as the dimension. If you then click OK, the chart pops up correctly.

This definitely looks like a bug to me. But I see nothing for "adddimension" searching the customer portal or the forum. Is there somewhere else I look for known bugs? Or does QlikTech just not publish that information? I don't want to report a bug if it's already been reported, and surely someone else has run into this before now.

Do others see the same behavior? And again, does anyone have a macro adding a dimension that works in version 10 SR1?

johnw
Champion III
Champion III


Christian77 wrote: The thing is that neither mine nor yours work in QV 10.
What do we do?





John Witherspoon wrote:Another approach we've been looking into, but somehow never found the time to really do it, is to CLONE a hidden table and then remove all of the dimensions and expressions you don't need. Since each user would then have a different table ID, there wouldn't be conflicts to crash it.


I don't have the code cleaned and tested to the point where I'm happy posting it, but I thought I'd let you know that I have this approach up and running and will probably post it in the next few days if it all tests out OK. It appears to work fine in version 10.

I believe this fixes both errors I know about with the old approach - two users modifying the same object on the server could crash the application or hang their user session, and there have been mild to serious problems adding dimensions depending on the QlikView version.

johnw
Champion III
Champion III

I decided to make a new thread for discussing the new approach and the new code.

http://community.qlik.com/forums/p/43233/171508.aspx#171508

pover
Luminary Alumni
Luminary Alumni

John, I read this post after your other post, so I just want to add that I haven't reported it as a bug and I'm not sure whether it is reported. Since I found the bug when working on a personal project and not on a customer's application, I didn't take the time to send an e-mail to QV support since I also assumed that I wasn't the first. I hope everybody doesn't assume that...

johnw
Champion III
Champion III

OK, I'll try to remember to report the bug next week using the example and the additional information you gave me in the other thread. Probably someone already has, but better to be sure.

christian77
Partner - Specialist
Partner - Specialist

Yes you can.

Some examples from APIGuide. Use a macro. Select your field. In the macro, GetPossibleValues, and then...

Rem Dynamic Data Update

sub Update
  SET Result = ActiveDocument.DynamicUpdateCommand ("UPDATE * SET Discount = if(Discount >= 35, 0, if (City='Stockholm', Discount + 5, Discount + 2)) WHERE Country = 'SE'")
  if Result = false then
    MsgBox Result.ErrorMessage
  end if 
end sub

sub Insert
  SET Result = ActiveDocument.DynamicUpdateCommand ("INSERT INTO * (Country, City) VALUES (DK, Copenhagen), (NO, Oslo)")
  if Result = false then
    MsgBox Result.ErrorMessage
  end if 
end sub

sub Delete
  SET Result = ActiveDocument.DynamicUpdateCommand ("DELETE FROM CITY WHERE IsNull (Discount)")
  if Result = false then
    MsgBox Result.ErrorMessage
  end if 
end sub

Not applicable
Author

Hey John,

could you please explain to me how the expressions are defined in the macro. What tells the macro what kind of expression should be applied?

Best Regards

Thorsten

johnw
Champion III
Champion III

The expressions are not defined in the macro.  The expressions are defined in the table.  The macro merely enables and disables them as required.