Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
jjustingkm
Creator
Creator

Dual() in load script

I have an indicator field IND with values 'Y' and 'N' . Would like to know, how to apply dual on this field in the load script, then Y would be displayed first.

1 Solution

Accepted Solutions
stevejoyce
Specialist II
Specialist II

Is this what you are looking for? 

dual(FlagText, pick(match(FlagText, 'Y','N'), 1, 2)) as Flag

View solution in original post

2 Replies
stevejoyce
Specialist II
Specialist II

Is this what you are looking for? 

dual(FlagText, pick(match(FlagText, 'Y','N'), 1, 2)) as Flag

Vegar
MVP
MVP

The solution by  @stevejoyce  will do the trick. 

An alternative solution is to use a mapping table in combination applymap() or MAP ... USING ... in the case where I have several fields that I need to map. 

MAP_YES_NO:
MAPPING LOAD
  TXT,
  dual(TXT, NUM) as DUAL
INLINE [
  TXT, NUM
  Y, -1
  N, 0
  ];


MAP IND, EVEN, ODD USING MAP_YES_NO;
TABLE:
LOAD
  ID,   //applymap('MAP_YES_NO', ID) as ID
  PRIME,//applymap('MAP_YES_NO', PRIME) as PRIME
  EVEN, //applymap('MAP_YES_NO', EVEN) as EVEN
  ODD   //applymap('MAP_YES_NO', ODD) as ODD   
Inline [

   ID,PRIME,EVEN,ODD
   1, Y, N, Y
   2, Y, Y, N
   3, Y, N, Y
   4, N, Y, N
   5, Y, N, Y
   6, N, Y, N
   7, Y, N, Y
];