Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Can some one Tell me where can i use Dual function in Scrip
Give me some Example script
Thanks in Advance
Niranjan
Hi,
I Got some information Here community
You use dual() when you need both a text and a numeric representation of a value. For instance, maybe you have a priority field.
High
Medium
Low
That's great for display, but not good for sorting, or taking the max(Priority), that kind of thing. So we might instead define it like this:
LOAD dual(Text,Number) as Priority
INLINE [
Text,Number
High,3
Medium,2
Low,1
];
Now, there might be other and even better ways to handle this particular example, but that's kind of the idea.
Dates WOULD be a very good example if they didn't have their own format. A date has a text representation like 'May 6, 2010', and also a numeric represenation, 40304. Normally, you want to see the text version, but you often want to sort and do mathematical manipulation using the underlying numeric, such as adding days to get a new date. Dual() makes some other sort of field behave similarly, where the text representation is what is normally displayed, but there's still a number in there that you can sort by and manipulate mathematically.
Hi Hardik,
You can use Dual() for this purpose, it is a dual datatype what you have to do is
if(field='A', Dual('0-20000', 1),
if(field='A', Dual('20001-40000', 2),
'
'
'
'
Now in chart the values are automatically sorted by using the second parameter in Dual().
Hope this helps you.
Regards,
Jagan.
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. 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.
Example:
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.