Friday, December 18, 2015

Dual () Function in QlikView

QVNewbie#5 : Dual () Function in QlikView :


Dual () Function in QlikView is a most Powerful function which i personally use for sorting the data in most of my implementations. “Dual() function does the Artificial association of the String Field  to the given Number”.

Let`s take a sample Data to run through the Dual() function. I have a Days Field in my Data model. Now the Request is to sort this data as per the week Days. Data looks as below before sorting the data.
      
    Raw Data                                         QV Front end Before Sorting
                                 

           There are many ways to achieve the sorting Scenario, Below are few ways what i can imagine now.

  1. IF statement with DUAL() Function (We will see this in Detail in this post)
  2. Applymap with Dual Function (We`ll jump into this in my Next blog post “How to Use ApplyMap”) and
  3. Using Inline Table with  two fields, One for Days and another field for Sorting Number. Linking the Days field from INLINE Table to Transaction tables Days field by Forming a External  association.Then use this Sorting Number field in Sort Property of the List Box to Sort the Days Field (Expression Sort).

Code looks like below for our 1st approach (IF Statement and Dual() Function ) :



In your data model, if the Sort Field is also available in Table, then You may use them as below.


Once the above code changes are completed, Run the Script to get this changes reflected at frontend. If we take the Days Field at Frontend, It should now automatically Sorted, if not Change the Default Sort of the Field to ‘Numeric’.


Hope this helps. Thanks for reading the post and Happy Qliking !!!

No comments:

Post a Comment