Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have a question:
In this sample script:
DATA:
LOAD
*
Inline [
Campo1, Valor1
AAA, 111
BBB,222
]
;
DATA2:
LOAD
Campo1,
Valor1
Resident DATA
Where Campo2 = 'AAA'
;
DROP Table DATA;
Can I put a IF condition in WHERE to let the two names (Campo1 and Campo2)?
The problem is when loading some excel files in a loop, the field name is changing.
Thank you.
IMHO this is the best approach. The others are just workarounds.
Good luck,
Peter
What do you think about this solution:
DATA:
LOAD
*
Inline [
Campo1, Valor1
AAA, 111
BBB,222
]
;
LET vFile = FieldName(1,'DATA');
DATA2:
LOAD
$(vFile) as "Campo2",
Valor1
Resident DATA
Where $(vFile) = 'AAA'
;
DROP Table DATA;
For the other script:
For Each vFile in filelist *
DATA:
LOAD
*
FROM [$(vFile)];
LET vFile = FieldName(1,'DATA');
DATA2:
LOAD
Max(Floor([Creada])) as "Max_Fecha"
Resident DATA
Where NOT $(vFile) like 'Generado*';
Next vFile;
Need to load the objetive field in first position.
If you're sure that it's always the first column that you'll use in a WHERE clause, then that will work too. The only thing is that performance will not be ideal, but that isn't much of a problem if your Excel files aren't too big.
BTW In the FOR loop, add a DROP Table DATA; statement after the LET vFile... line or you may be joining all columns from all Excel files into a single DATA table. I'm assuming that the autoconcatenate that will happen on your DATA2 table is intended?
Peter
The excel files aren´t big.
The loop of the example is a little part of the load.
Thank you very much.