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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to reuse an expression without repeating code?

Hello everyone. I need help.
I created an expression and I have added to the PivotTable (field "VALUE").
Since I use this expression in different parts of the project I thought
create a variable and move the contents of the expression in there (VAR_NUMERATORE).

However, adding a column of type expression containing the variable created in
PivotTable I realized that the data will not be calculated as I want.

The result is that I would get represented in the "VALUE" column, while the wrong one
I would fix is in column "CALC_VALUE".

Does anyone have any suggestions?

Thanks for your support and sorry for my google-translated English [:)],

Capetto

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Please find the attachment and find the differences of Variable (usage. '=' and '$' usage specially).

regards, tresesco

View solution in original post

6 Replies
Not applicable
Author

Opsss... Here the example.

Not applicable
Author

Hello,

In your expression, to reuse one you've already created, you can use column(x) function.

It's very useful.

Hope this helps,

Yamaz

Not applicable
Author

Hi,

Correct expreesion of VALUE like this :

=Sum(

If(INDICATORE='A001' OR INDICATORE='A003' OR INDICATORE='A005' OR INDICATORE='A007' OR INDICATORE='A009' OR INDICATORE='A011',

(If(VALORE >= VALORE_MIN AND VALORE <= VALORE_MAX, VALORE,0)),

If(INDICATORE='A002' OR INDICATORE='A004' OR INDICATORE='A006' OR INDICATORE='A008' OR INDICATORE='A010',

(If(VALORE >= VALORE_MIN AND VALORE <= VALORE_MAX, 1,0)))))



and then CAL_VALUE give it in Expression popup =[VALUE]

may it will gives you correct answer

Regards,

Santhosh

Not applicable
Author

Column(x) function can be used only in the same object. I need to use this expression in another objects (graphics and tables).

Capetto

tresesco
MVP
MVP

Please find the attachment and find the differences of Variable (usage. '=' and '$' usage specially).

regards, tresesco

Not applicable
Author

Perfect!!! It works very well.

Thank you very much,

Capetto