Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, i am new in this and i have a problem that for sure would be very easy to solve it.
If i have to columns with different data. For example:
I want to change just the ones that are named Web in the column A to Web in the Column B
1) | 2) | |||
A | B | A | B | |
CC | Murcia | CC | Murcia | |
Web | Andalucia | Web | Web | |
Direct | Cataluña | Direct | Cataluña | |
Web | Madrid | Web | Web | |
CC | Murcia | CC | Murcia | |
Direct | Asturias | Direct | Asturias |
It is that possible?
Thanks
Try the following script:
SecondTable:
load
A as _A,
if(A = 'Web', A,B) as _B
resident FirstTable;
drop table FirstTable;
rename field _A to A;
rename field _B to B;
rename table SecondTable to FirstTable;
Hi.
It's possible. You can do it easily in script or at front-end.
The most flexible way to achieve this is by using a mapping table. If() statements are fine as long as the code never needs to change, but what if you decide in the future that 'CC' should change to 'Web' as well?
Let's assume you have an Excel spreadsheet that contains the values in field A that should be changed and what they should change to. E.g.:
FieldA | FieldB |
---|---|
Web | Web |
Net | Fish |
Rabbit | Tasty |
In your QV script, load this as a mapping tbale:
Map_FieldB:
MAPPING LOAD
FieldA,
FieldB
FROM....MappingSpreadsheet...;
Then, when loading your data, refer to this mapping table using ApplyMap() with FieldB as the third parameter so that for all FieldA values not in the mapping table, the original value of FieldB will be returned:
Data:
LOAD
FieldA,
ApplyMap('Map_FieldB',FieldA,FieldB) AS FieldB
FROM....;
Hope this helps,
Jason
Hi,
Try this,
Load A,
If(A='Web',A,B) AS B;
Load A,
B
from YourTable;
Hope it help you.