Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
dmohanty
Partner - Specialist
Partner - Specialist

Select in Field Action - Can we pass multiple Field Names and Values?

Hi All,

Can we pass multiple Field Names and their respective Field values in a Single 'Select in Field' or 'Select Possible' action of a Button?

This is a requirement I need, so that if I click on an APPLY Button, those Fields and Values get selected. But I don't want to hard-code those values in Action; those has to be passed dynamically.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

17 Replies
swuehl
MVP
MVP

I believe you'll need an action per field selection, but you can assign the field names dynamically ('field' is an expression entry box as well as the search string).

dmohanty
Partner - Specialist
Partner - Specialist
Author

Hey Swuehl,

Can you please help more here with example?

In below image, for the selection = BM01-51 , I have the Possible Values in next two List Boxes.

BookmarkFieldName has the list of Fields to be used in Select in Field/Select Possible action.

BookmarkFieldValue has the list of corresponding values to be passed in Search String.

I want to dynamically pass the BookmarkFieldName field names, whenever the Bookmark_ID value is selected.

BM_1.jpg

qlikviewwizard
Master II
Master II

Hi Try this.

Hope this will help you.

Capture1.JPG

jagan
Luminary Alumni
Luminary Alumni

Hi,

This is not possible normal triggers, since you have different number of fields for each bookmark.  So you have use the macro with some looping and then select the values based on that.  You can find some sample piece of code from

Useful Qlikview Macros

  1. SUB SelectValues
  2.   SET Doc = ActiveDocument 
  3.   fieldName = "BookmarkFieldName" 
  4.   SET Field = Doc.Fields(fieldName).GetPossibleValues 
  5.  
  6.   FOR index = 0 to Field.Count-1 
  7.   Doc.Fields(fieldName).Clear 
  8.   Doc.Fields(fieldName).SELECT Field.Item(index).Text    
  9.   fieldName1 = "BookmarkFieldValue" 
  10.   SET Field1 = Doc.Fields(fieldName1 ).GetPossibleValues
  11.   FOR subindex = 0 to Field1.Count-1
  12.      Doc.Fields(fieldName1).SELECT Field1.Item(subindex ).Text
  13.   NEXT
  14.  
  15.   Doc.Fields(fieldName).Clear 
  16. END SUB
dmohanty
Partner - Specialist
Partner - Specialist
Author

Hi Jagan,

Thank you for the great help here.

I applied the Macro action in the Button, but when I am clicking, only ONE  possible value from BookmarkFieldName comes and ONE value is selected from BookmarkFieldValue. Image below:


BM_2.jpg

Where as I need a selection set like this below:

BM_3.jpg

jagan
Luminary Alumni
Luminary Alumni

Hi,

Attach sample file and your expected results so that it would be easier to understand and provide the solution.

Regards,

jagan.

dmohanty
Partner - Specialist
Partner - Specialist
Author

HI Jagan,

Attach is the file and the source. Could you please support here?

  • I am loading all the Data from the QVD.
  • From the BookmarkFieldName and BookmarkFieldValue , I need the values to be used as Fields so that they can be used in Action of a Button.
  • Whenever the Document Name and Bookmark_ID is selected, the Possible values from BookmarkFieldName and BookmarkFieldValue are listed.

BM_1.jpg

  • I need those possible values used as Fields and gets selected upon Clicking the Button.

BM_3.jpg

swuehl
MVP
MVP

As far as I understand, you don't want to select values in BookmarkFieldName, but use these values as field names to select in.

For example, you want to get 'Previous Month' used as field name with a selection of 'Active', right?

But your sample data does not show any field named like that...

If you just want something like shown in the second picture of your previous post, this should do:

  1. SUB SelectValues
  2.   SET Doc = ActiveDocument

  3.   fieldName = "BookmarkFieldName"
  4.   Doc.Fields(fieldName).SELECT "*"

  5.   fieldName1 = "BookmarkFieldValue"
  6.   Doc.Fields(fieldName1).SELECT "*"
  7. END SUB
dmohanty
Partner - Specialist
Partner - Specialist
Author

Hey Swuehl,

Your Macro Solution worked superb! Many Thanks.

And Your Understanding is CORRECT.

  • I really need those values in BookmarkFieldName and BookmarkFieldValue to be converted to Field Names and are to be selected using a Button. For example, I want to get 'Previous Month' used as field name with a selection of 'Active',
  • Now I have tried converting the values BookmarkFieldName and BookmarkFieldValue using Generic Load (Attached updated QVW). Now it has those fields, that you didn't find earlier.
  • But after the Generic Load script, the Data Model is HUGE, as it has all the Generic Tables. I have tried using the below script to Join them to main table and finally drop one by one - BUT, It takes a Long and Long time and consumes full usage of RAM, making the system dead slow. Any help here will be much helpful too

//////   JOIN & DROP loop to consolidate the Generic tables

FOR i = NoOfTables()-1 to 0 STEP -1
LET vTable=TableName($(i));
IF WildMatch('$(vTable)', 'Generic.*') THEN
LEFT JOIN (BM) LOAD * RESIDENT    [$(vTable)];
DROP TABLE  [$(vTable)];
ENDIF
NEXT i


  • Once I get those values in BookmarkFieldName and BookmarkFieldValue to be converted to Field Names, I really need those Fields and Values to be selected like in screenshot below:

BM_4.jpg