Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Load Script IF statement Help

Hi All,

I’m trying to add an IF statement to my load script. What I’m
trying to do here is to rename the ‘Status’ if it meets this condition. For
example:  (see below).

Temp:
Load * Inline
[
Name, Status
Apple, Red
Banana, Yellow
Orange, OK
Pear, Green
]
;

If(Status=(’Red’,‘Yellow’), Status=’Approved’

If(Status=(’Green’),’OK’,Status))

Many Thanks,

Frank

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

Temp:

Load

     *,

     If(Match(Status,'Red','Yellow'),'Approved',

     If(Match(Status,'Green'),'OK', Status)) as NewStatus

Inline
[
Name, Status
Apple, Red
Banana, Yellow
Orange, OK
Pear, Green
]
;

View solution in original post

8 Replies
pamaxeed
Partner - Creator III
Partner - Creator III

You can do something like that:

Status:

Load Name,

         Status,

         if(Status = 'Red' or Status = 'Yellow', 'Approved', if(Status='Green', 'OK', Status)) as NewStatus

Resident Temp;

Cheers,

Patric

MK_QSL
MVP
MVP

Temp:

Load

     *,

     If(Match(Status,'Red','Yellow'),'Approved',

     If(Match(Status,'Green'),'OK', Status)) as NewStatus

Inline
[
Name, Status
Apple, Red
Banana, Yellow
Orange, OK
Pear, Green
]
;

Kushal_Chawda

try

Load *,If(match(Status,'Red','Yellow'),'Approved',if(Status='Green','Ok',Status)) as Field Inline
[
Name, Status
Apple, Red
Banana, Yellow
Orange, OK
Pear, Green
]
;

pamaxeed
Partner - Creator III
Partner - Creator III

Other possibility is to use a Mapping Load just like this:

MapToStatus:

Mapping LOAD * Inline [

Status, NewStatus

Red, Approved

Yellow, Approved

Green, OK

];

Temp:

Load * Inline

[

Name, Status

Apple, Red

Banana, Yellow

Orange, OK

Pear, Green

];

Status:

Load Name,

     Status,

     ApplyMap('MapToStatus', Status) as NewStatus

Resident Temp;

Drop Table Temp;

maxgro
MVP
MVP

one more

Temp:

Load

  Name,

  Status,

  pick(WildMatch(Status, 'Red', 'Yellow', 'Green', '*'), 'Approved', 'Approved', 'OK', Status) as NewStatus

Inline

[

Name, Status

Apple, Red

Banana, Yellow

Orange, OK

Pear, Green

];

Anonymous
Not applicable
Author

Hi All, Thanks for all the replies. All works like a charm!!!

Frank


Anonymous
Not applicable
Author

Patric,

Yours works well with AND as well. I added a DATE fied where one is blank and wanted to show as "Outstanding"

Name, Status, Date

Apple, Red,1/1/2015

Banana, Yellow,2/2/2015

Orange, OK

Pear, Green,3/2/2015

Load Name,

     
Status,

     
if(Status<>'' and Date='', 'Outstanding',

     
if(Status = 'Red' or Status = 'Yellow', 'Approved',

     
if(Status='Green', 'OK', Status))) as NewStatus

Resident Temp;

Anonymous
Not applicable
Author

Manish,

Can it add AND to the IF statement? not sure how it works with "Match"

such as:

If Name<>blank AND Date=blank, "Outstanding"

I added something like this to your If statement and it works.

IF ([Status]<>'' and IsNull([Date]) or [Date]='', 'Outstanding',

     If(Match(Status,'Red','Yellow'),'Approved',

     If(Match(Status,'Green'),'OK', Status)) as NewStatus

Name, Status, Date

Apple, Red,1/1/2015

Banana, Yellow,2/2/2015

Orange, OK

Pear, Green,3/2/2015