Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Alias Dinamico / Dynamic Alias

Pessoal, estou com um problema para gerar um alias dinamico, por exemplo, eu tenho uma tabela com id, campo e valor; (campo é o nome do campo relacionado ao valor e valor o valor deste campo), tentei fazer o seguinte:

extras:

LOAD id,

          valor as campo;

SQL ........... Sendo que este SQL me retorna esta estrutura de id, campo e valor.

Porém , ao fazer este script acima é como se ele ignorasse a linha "valor as campo", pois não faz nada, quando olho as estruturas das tabelas, a tabela extra só possui o campo id.

Alguem consegue me ajudar? Abraços

Hello, i'm with a problem to create an dynamic alias, for example: i have a table with the fields id, field, value; (field contains the name of the fields related to values, and value is the value of the field ), i tried to do the following:

extras:

LOAD id,

  value as field;

SQL ........... SQL returns this structure of id, field, value.

But, when i execute this script it ignores the line "value as field", because nothing happens, and when i see the tables structures, the table 'extra' only has the id field.

15 Replies
Not applicable
Author

I think your problem is in ";"  then the second field. To upload data structure would be:

extras:

LOAD id,

            value as field

SQL.......................

danielrozental
Master II
Master II

Guilherme, can you post your entire script?

Not applicable
Author

I tryed it, but it doesn't work. It needs a ';' in the end of the LOAD to start the SQL query.

Someone have user a dynamic alias? The solution can be in qlikview, or if someone know how, in mysql. I tryed in both to use dynamic alias, but didn't work. Only to explain, my table contains in the field called 'Field' the Fields of other table and the 'value' field the values, i need to use these values of the 'field' field like alias of the values of the 'values' field.

danielrozental
Master II
Master II

It might be that you're using a QlikView reserved word or something, try using brackets

LOAD ID

     value as [Field];

SQL SELECT ID, value FROM table;

Not applicable
Author

The tables SQL Querys are to extensive, so, i will replace it for SQL ...., script follows bellow:

OLEDB CONNECT TO ..........( it's ok, i already tested it)

extraFields:

LOAD id,

          field,

          value as field; (Remember that 'value' and 'field' are table fields)

SQL Select .... (This query returns the 'id', 'field' and 'value')

I need to use the values of 'field' like alias to the values in the 'value' field. This is the script.

Not applicable
Author

I tryed it too, when i put 'Field' between [], it behaves like a String, and i tryed to use expression like:

extraFields:

LOAD id,

          field,

          value as [ $(=field) ];

SQL Select ....

But, didn't work too.

danielrozental
Master II
Master II

Sorry, I'm not following, what do you mean they are dynamic?

You should probably use variables and do something like

Let vValue = 'Value';

Let vField = 'Field';

LOAD ID,

     $(vValue) as [$(vField)];

SQL SELECT * FROM TABLE;

danielrozental
Master II
Master II

You can't use the field content as a field name in the LOAD.

You would need to that in the script, doing a for or something.

Not applicable
Author

This way I used to extract data from SQL Server:

Table1:

SQL HereYourQuery ;

Regards.