Tuesday, June 15, 2010

Restoring the selection for a single field from a bookmark



When you create a QlikView Bookmark to save your current selections it saves all of the selections for all of the fields where you’ve made a selection in your document. Often, that’s the reason you’re saving the selections as a bookmark – because it’s a complex set of selections for several fields that would take a while to recreate the next time you need them.

Sometimes, it would be nice to restore the selection from a bookmark for just one field. For example, if you have a bookmark named Project_3 that was used to save a complex selection from your monthly sales report, you might want to use only the part of that bookmark that is a selection on the Ship_Date field.

The way you would do that is to click on a listbox in your document for the Ship_Date field or click on the Ship_Date row in a multibox to activate the object. Then, start typing, make sure you begin typing with an equal sign (so that QlikView knows that you are beginning to type an expression). Type this:
=sum( { Project_3 } 1 )


That expression when typed into the selection box for Ship_Date will select only the Ship_Date values that are saved within the Project_3 bookmark. An expression like that can also be used with the Advanced Selection dialog box.

Remember that bookmarks can be exported and imported into other documents. You can even import bookmarks into documents quite different from the original document where the bookmark was created; when you do that the bookmark selections will be applied only to the fields named exactly the same as in the original document.
★ ★ ★

3 comments:

Anonymous said...

How can I use the bookmarks within sheets of a single QVW document? For example, I've three tabs on my .QVW application tab a1, b1 and c1. When I am in a1 I make few selections, but when I move on to tab b1 I want all the selection in a1 to get cleared and start with brand new selection in tab b1. However, when I come back to tab a1, I want to clear all the selection made in b1 and restore the previous selection made in tab a1. How can I preserve the selections everytime from tab to tab and reapply them when I come back to that tab?

Anonymous said...

How can I use the bookmarks within sheets of a single QVW document? For example, I've three tabs on my .QVW application tab a1, b1 and c1. When I am in a1 I make few selections, but when I move on to tab b1 I want all the selection in a1 to get cleared and start with brand new selection in tab b1. However, when I come back to tab a1, I want to clear all the selection made in b1 and restore the previous selection made in tab a1. How can I preserve the selections everytime from tab to tab and reapply them when I come back to that tab?

-TB said...

I've seen QlikView documents that use a macro triggered by activating or leaving a tab that will clear previous selections and then apply selections saved the last time the tab was activated.

Clearing selections is easy. Saving the current selections means using the API to save selected values for each field into a global array. It's more than I could describe in a comment. You might get someone to contribute sample code if you post your question in the QlikCommunity forum.