Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Partner
Partner

dynamic field name

Hi All,

I have 20 fields like A,B,C,D,E,F.... etc.

then i created a inline table to get a dimension with the name above fileds.

i.e.

load * inline[

Filed_Name

A,

B,

C,

D,

E,

F

];

Now i want to create a table. so i write expression like

if(Filed_Name='A',sum(A),

if(Filed_Name='B',sum(B),

if(Filed_Name='C',sum(C).....)

etc.

so i need instead of write separate expression for each dimension value, can i get common expression like below

sum(max(field_Name)) or Sum(only(field_Name)) or can use variable?

how can i get field name from field value?

9 Replies
Partner
Partner

Re: dynamic field name

hi

you can use

=$(='Sum(' & Filed_Name & ')')

MVP
MVP

Re: dynamic field name

Or this:

    Sum($[(=field_Name)])

But neither of these will work unless there is one and only one possible value of field_Name (eg by selecting one value from the list).

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
MVP
MVP

Re: dynamic field name

If you want to display all of them in a table, load the data like this:

FieldDims:

LOAD Dual(field_Name, RowNo()) as field_Name

Inline

[

field_Name

  A,

  B,

  C,

  D,

  E,

  F

];

Create a table with field_Name as dimension, and use the expression:

=Pick(field_Name,

  Sum(A),

  Sum(B),

  Sum(C),

  Sum(D),

  Sum(E),

  Sum(F)

)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Partner
Partner

Re: dynamic field name

Hi Liron,

Thanks for your reply.

But it is not working for me.

my field names are [stress value], [long/short value].

MVP & Luminary
MVP & Luminary

Re: dynamic field name

Could it be that your source is a crosstable? If yes it might be easier to transform it into a normal data-structure per The Crosstable Load.

- Marcus

Partner
Partner

Re: dynamic field name

hi

try this

=$(='sum([' & Field_Name & '])')

Partner
Partner

Re: dynamic field name

Hi Liron,

Thanks for your reply.

it is working when we select a value on that field. but i need without making selection of that field can we get the result?

Highlighted
MVP & Luminary
MVP & Luminary

Re: dynamic field name

I think this won't be possible because the $-sign expansion will be globally calculated and contained then as an adhoc-variable a single-value - it won't be calculated in respect to any dimensions.

- Marcus

Partner
Partner

Re: dynamic field name

Hi Marcus,


Thanks for your reply.