Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Dynamic expression generated by string concatenation based on user input

Is is possible to form an expression dynamically in script? For example, I would like to have a sum function, where columns to sum are based on user input.

In the script, I defined a variable to form the full expression:

Set vSumFieldSelections = 'Sum([' & GetFieldSelections([fieldName],']+[') & '])';

Then my expression in one of the QlikView text object:

=$(vSumFieldSelections)

Thanks

3 Replies
Not applicable

Re: Dynamic expression generated by string concatenation based on user input

Hi,

PFA

Hope it helps.

Re: Dynamic expression generated by string concatenation based on user input

As per my knowledge, in the script level its not possible to get the sum of certain values based on the user selection but you can achieve it in the front get .

Re: Dynamic expression generated by string concatenation based on user input

May be this, set the Expression to the variable then you can use it.

like

set v1='Sum(IDcount)';

set v2='Sum(Aggr(Sum(IDcount), DimA,DimB))';

Set vSumFieldSelections = '=Sum({<DimA=P()>}[DimA])';


LOAD * INLINE [

     ID, DimA, DimB, IDcount

    2810, 23, 1849, 1

    2851, 24, 1849, 1

    4098, 28, 2710, 1

    5890, 30, 3891, 1

  ];

PFA for reference.

Hope this helps.

Community Browser