Saturday 29 August 2009

Using Dual

QlikView has a really cool data type called "Dual". This type allows you to mix text and numeric values which can be very useful.

For example, imagine that you had some pieces of text, say:

Apr, Aug, Dec, Feb, Jan, Jul, Jun, Mar, May, Nov, Oct, Sep

And you would prefer to have them sorted in another order, say:

Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

Then we could load this something like:

Load
Dual(Name, Num) As Month;
LOAD * INLINE [
Num, Name
1, Jan
2, Feb
3, Mar
4, Apr
5, May
6, Jun
7, Jul
8, Aug
9, Sep
10, Oct
11, Nov
12, Dec
];

And the Month field would be sorted in the correct order.

If we need to get the component values spearately out of a Dual value, we can use Num and Text:

Text(Month) & ' (' & Num(Month) & ')'

Might give us a result of:

Apr (4)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.