Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'ld like to rename a field in my script like that :
LOAD
Sta as [Sta Field];
IF(Sta= 'A' , 'Active',
IF(Sta= 'B', 'Beginning',
IF(Sta= 'C', 'Close')));
SQL SELECT Sta
FROM TABLE;
But that's didn't work. Can you give me some advice pliz ?
Erwan,
Map1:
Mapping LOAD * INLINE [
Colkey, ColReplace
A, Active
B, Beginning
C, Close]
(the names of the columns do not matter)
Afterwards,
Load .....,
ApplyMap('Map1', STA) as xxx
.....
Assuming that STA is A, B or C. If sth else, Applymap will return null() except if you set a 3d argument, sth like 'STA not found'.
Fabrice
Hi try like this,
Load
Sta as [sta Field];
if(match(sta='A','Active',
IF(match(Sta= 'B', 'Beginning',
IF(match(Sta= 'C', 'Close')));
Hi Erwan
First of all remove semicolon after [Sta Field]
Sta as [Sta Field];
Then put some column name for the column with If statements
IF(Sta= 'C', 'Close'))) AS [Sta Name];
You also may like you use mapping table/applymap for this instead of nested If
Lukasz
Erwan,
Do you want to rename field or field value ?
If it is the value, you can use ApplyMap() function.
First you load a 2 field table with the Mapping Load statement. You will have A - Active, B - Beginning ...
Second, you load your table & your field :
LOAD .... applymap('MapTable', Value) as XXXX
(the value is A, B, C : the first column of the mapping table)
Fabrice
Just as an Example
TableA:
LOAD * Inline [
Sta
A
B
C
];
LOAD Sta as Sta1 ,if(Sta='A','Active',IF(Sta='B','Begining',IF(Sta='C','Cancel'))) as Sta2 Resident TableA;
Thx for your help. You are right, I want to rename/change my value. I'll try the applymap function.
In my list, I've this :
Sta :
And I want this :
Btw I'm a beginner on QlikView and i'm not very proud of my English.
Erwan,
Map1:
Mapping LOAD * INLINE [
Colkey, ColReplace
A, Active
B, Beginning
C, Close]
(the names of the columns do not matter)
Afterwards,
Load .....,
ApplyMap('Map1', STA) as xxx
.....
Assuming that STA is A, B or C. If sth else, Applymap will return null() except if you set a 3d argument, sth like 'STA not found'.
Fabrice
Hi Erwan,
Just replace the semi colon with comma, after the [Sta Field] and then try it. It should work.
corrected script
LOAD
Sta as [Sta Field],
IF(Sta= 'A' , 'Active',
IF(Sta= 'B', 'Beginning',
IF(Sta= 'C', 'Close')));
SQL SELECT Sta
FROM TABLE;
Work great!
Thank you a lot Fabrice.