Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
jeevays7
Partner - Creator III
Partner - Creator III

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
lironbaram
Partner - Master III
Partner - Master III

hi

you can use

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

jonathandienst
Partner - Champion III
Partner - Champion III

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
jonathandienst
Partner - Champion III
Partner - Champion III

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
jeevays7
Partner - Creator III
Partner - Creator III
Author

Hi Liron,

Thanks for your reply.

But it is not working for me.

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

marcus_sommer

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

lironbaram
Partner - Master III
Partner - Master III

hi

try this

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

jeevays7
Partner - Creator III
Partner - Creator III
Author

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?

marcus_sommer

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

jeevays7
Partner - Creator III
Partner - Creator III
Author

Hi Marcus,


Thanks for your reply.