Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikview979
Specialist

DUAL FUNCTION

Hi experts,

What is DUAL function ?

5 Replies
Anonymous
Not applicable

dual() function is used for loading column with text as well as numeric value for the same.

Its generally used in Quarter calculation and in sorting

See the ex.  from QlikView help file -

dual( s , x )

Forced association of an arbitrary string representation s with a given number representation x. In QlikView, when several data items read into one field have different string representations but the same valid number representation, they will all share the first string representation encountered. This function can be used in scripts and chart expressions.

In scripting, the dual function is typically used early in the script, before other data is read into the field concerned, in order to create that first string representation, which will be shown in list boxes etc.

Note!
If a dual value is too large to fit in a field object, it will be represented by ## and not truncated with ... like a string.

Example (scripting):

load dual ( string,numrep ) as DayOfWeek inline

[ string,numrep

Monday,0

Tuesday,1

Wednesday,2

Thursday,3

Friday,4

Saturday,5

Sunday,6 ];

load Date, weekday(Date) as DayOfWeek from afile.csv;

The script example will generate a field DayOfWeek with the weekdays written in clear text. QlikView will for all purposes regard the field as a numeric field.

Thanks

BKC

julian_rodriguez
Partner - Specialist

Hello Mahesh

It's a function to represent data in both text and numeric format.

For example: Dual('January', 1): this will create a field value with a mask "January" and a numeric value "1".

See the help's definition:

dual( s , x )

Forced association of an arbitrary string representation s with a given number representation x. In QlikView, when several data items read into one field have different string representations but the same valid number representation, they will all share the first string representation encountered. This function can be used in scripts and chart expressions.

In scripting, the dual function is typically used early in the script, before other data is read into the field concerned, in order to create that first string representation, which will be shown in list boxes etc.

Note!
If a dual value is too large to fit in a field object, it will be represented by ## and not truncated with ... like a string.

Example (scripting):

load dual ( string,numrep ) as DayOfWeek inline

[ string,numrep

Monday,0

Tuesday,1

Wednesday,2

Thursday,3

Friday,4

Saturday,5

Sunday,6 ];

load Date, weekday(Date) as DayOfWeek from afile.csv;

The script example will generate a field DayOfWeek with the weekdays written in clear text. QlikView will for all purposes regard the field as a numeric field.

stevedark
Partner Ambassador/MVP

I can see that this has already been answered, but just to add a few more notes.

Dates in QlikView are all dual values, that is they have a text and a numeric representation.  That is why 8 May 2015 - 2 May 2015 will give you 6.

Duals can be useful for any text that you want to sort in a different order to alphabetical, for example a workflow.  You can make Initial Contact = 1, through to Sale Closed = 11, with other steps in between.  The items can then sort on the number, but be displayed as the text.

A big gotcha with duals is that if you apply the same number to two different bits of text and show them in a list box, QlikView will only show one of the items of text.  It always gives numeric values precedence, so in that case it would assume that there is only one value, not two.

Hope that helps clarify a bit.  There is a lot more information on-line if you Google QlikView Dual.

Steve

ankitbisht01
Creator

hey You can refer to this link  very simple explanation QlikView Addict: QlikView Functions: dual():