Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Highlighted
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

Alias Dinamico / Dynamic Alias

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

extras:

LOAD id,

            value as field

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

danielrozental
Honored Contributor II

Alias Dinamico / Dynamic Alias

Guilherme, can you post your entire script?

Not applicable

Alias Dinamico / Dynamic Alias

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
Honored Contributor II

Alias Dinamico / Dynamic Alias

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

Alias Dinamico / Dynamic Alias

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

Alias Dinamico / Dynamic Alias

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
Honored Contributor II

Alias Dinamico / Dynamic Alias

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
Honored Contributor II

Alias Dinamico / Dynamic Alias

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

Alias Dinamico / Dynamic Alias

This way I used to extract data from SQL Server:

Table1:

SQL HereYourQuery ;

Regards.