Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
plz help me out with different ways to rename a field or to rename a column name of Inline table with a sample code.
regards,
Mandar
Syntax would be
RENAME FIELD OldFieldName TO NewFieldName;
RENAME FIELDS OldName1 TO NewName1, OldName2 TO NewName2, OldName3 TO NewName3;
And my favorite:
FieldNamesMap:
MAPPING LOAD OldName,
NewName
FROM File.qvd (qvd);
RENAME FIELDS USING FieldNamesMap;
Miguel
use alias
like
[FieldName] as [NewFieldName]
Hi mandar,
Try this
Temp:
Load * Inline [
Month, Sales
Jun, 123
Jul, 234
Aug, 432
];
Load Month as MonthName,
Sales as SalesAmount
Resident Temp;
-- Regards,
Vishal Waghole
In inline table you can rename a field with different approach
Ex:-
Load Field1 as Customers ,Field2 as Sales; //By this line as preceding load you can rename
Load * Inline
[
Field1,Field2
A,100
B,200
C,300
D,400
];
Ex:- Or by any resident load you can rename the field
Tab1:
Load * Inline
[
Field1,Field2
A,100
B,200
C,300
D,400
];
NewTable:
Load
Field1 as Customers ,
Field2 as Sales
Resident Tab1;
Drop Table Tab1;
Hi Mandar,
Try this code
Load MonthID as DateID,Month inline [
MonthID,Month
1,Jan
2,Feb
];
You can use
Rename OldFieldName to NewFieldName;
Eduardo
you can also have a list in e.g. an excel looking like that
original name, new name
...,...
...
and at the end of the script you can do like that
rename fields using excelfile.xlsx;
Syntax would be
RENAME FIELD OldFieldName TO NewFieldName;
RENAME FIELDS OldName1 TO NewName1, OldName2 TO NewName2, OldName3 TO NewName3;
And my favorite:
FieldNamesMap:
MAPPING LOAD OldName,
NewName
FROM File.qvd (qvd);
RENAME FIELDS USING FieldNamesMap;
Miguel
Hey Mandar,
Be sure to use the Qlik Sense Help. Below is the entry for Rename Field.
This script function renames one or more existing Qlik Sense field(s) after they have been loaded.
Either syntax: rename field or rename fields can be used.
Syntax:
Rename Field (using mapname | oldname to newname{ , oldname to newname })
Rename Fields (using mapname | oldname to newname{ , oldname to newname })
Arguments:
Argument | Description |
---|---|
mapname | The name of a previously loaded mapping table containing one or more pairs of old and new field names. |
oldname | The old field name. |
newname | The new field name. |
Limitations:
Two differently named fields cannot be renamed to having the same name. The script will run without errors, but the second field will not be renamed.
Example 1:
Rename Field XAZ0007 to Sales;
Example 2:
FieldMap:
Mapping SQL Select oldnames, newnames from datadictionary;
Rename Fields using FieldMap;
Hola Miguel
Las dos opciones sugeridas me funcionan bien, tanto para renombrar campos como para mantener el vínculo entre los objetos de presentación con los campos renombrados.
Esto, claro está, si lo hago en un documento de prueba.
Pero, sucede que tengo un documento con 600+ campos, y al renombrarlos con cualquiera de las opciones descritas, los objetos quedan desvinculados al campo nuevo y debo volver a asignarlos, bien sea uno por uno, o por el diálogo "Vista prievia de la Expresión (Ctrl+Alt+E)".
Existe un límite en el número de campos que se puedden renombrar sin que se pierda el enlace entre el objeto/expresión/variable que lo contiene, para que Qlikview lo reemplace de manera automática?
Debo entonces cambiar todo manualmente?
Gracias por tus comentarios