Hi,
I'm sure this must be really straightforward, but I can't find a solution anywhere!
I have a field with lots of different values, and I want to use these values to create a new field, with only 3 values, in the script.
E.g.
Temperature
0
12
100
30
25
1
0
100
I want a new field called 'Description' that gives the value 'Freezing' if the Temp is = 0, 'Boiling' if the Temp is = 100, and 'Between' if the the Temp is neither 0 or 100.
Thanks,
Jess
hi!
load
Temperature,
if(Temperature=0,'Freezing',
if(Temperature=100,'Temp=100', 'Between')) as Temp
from ....
Try this:
Table:
LOAD *,
Pick(Match(Temperature, 0, 100, Temperature), 'Freezing', 'Boiling', 'Between') as Description;
LOAD * Inline [
Temperature
0
12
100
30
25
1
0
100
];
hi!
load
Temperature,
if(Temperature=0,'Freezing',
if(Temperature=100,'Temp=100', 'Between')) as Temp
from ....
Hi,
Temprature:
LOAD *,
If(Temperature = 0 , 'Freezing',
IF(Temperature = 100, 'Boiling',
If(Temperature >0 AND Temperature < 100, 'Between'))) As Description;
Load * Inline [
Temperature
0
12
100
30
25
1
0
100
];
Thanks,
V.
Hi,
I will advocate for using PICK() and MATCH() Function simply for load performance.
Try this:-
Temperature_Data:
LOAD *
,PICK(MATCH(Temperature, 0 , 100 , Temperature),'Freezing','Boilong','Between') AS Description
;
LOAD * INLINE [
Temperature
0
12
100
30
25
1
0
100
];
EDITED because I notice this same suggestion above
You may use the following script in order to take care of temperatures other than 0 and 100 correctly.
Temprature:
LOAD *,
If(Temperature <= 0 , 'Freezing',
IF(Temperature >= 100, 'Boiling',
If(Temperature >0 AND Temperature < 100, 'Between'))) As Description;
Load * Inline [
Temperature
0
12
100
30
25
1
0
100
];
Hi,
Thanks for everyone's responses.
This solution is perfect (I should have mentioned that the list of different temperatures was a lot longer than my example, so an inline table wouldn't work).
Thanks again,
Jess