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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
ali_hijazi
Partner - Master II
Partner - Master II

Parameterized variables

Hello
I got a parameterized variable in my App defined as follows:
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)
so far it is working fine
but now I want to do a new logic inside the definition of this variable
I want to check if the value of the first parameter is 'actual' or 'budget' based on which there will be a new logic
I tried '$1' in an if condition but didn't seem to work
is there a way to accomplish this?

I can walk on water when it freezes
Labels (2)
6 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @ali_hijazi 

It is confusing what you are trying to do. 

Given that you need to pass parameter 1 to variable you dont need to check what it is as you alerady know what you are passing as that parameter.

You may want to explain it with some other example to help us understand.

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
ali_hijazi
Partner - Master II
Partner - Master II
Author

what I want to accomplish is the following:
when the value of the first parameter $1 is 'Actual' then
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)

otherwise

{<field1={'value'}>}
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)

I'm using this parameterized variable becuase it is used in several charts and I don't want to repeat the calculation expression and the condition in all charts but rather have it in one place

 

I can walk on water when it freezes
marcus_sommer

You may try:

{<field1={"$(=if($1 = 'Actual', 'value', '*'))"}>}
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)

In general should an if-query against a parameter be possible. Just check the if-logic at first without the parameter and afterwards the parameter is replaced by the condition-value.

Another approach may be:

{<field1={$5}>}
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)

ali_hijazi
Partner - Master II
Partner - Master II
Author

Hello @marcus_sommer 
it doesn't work as you suggested
if ($1 = 'actual'....
the editor gives an error

I can walk on water when it freezes
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @ali_hijazi 

Works for me:

Lech_Miszkiewicz_0-1733203471422.png

Lech_Miszkiewicz_1-1733203606290.png

 

As I said passing parameter you already know and have to pass anyway does not make sense to me as it adds more complexity, but at the end if you are happy with that approach here is a sample app. 

Obviously to accomodate $1 in If() condition you need create another variable with that parameter so that it can obtain and pass down the parameter you are trying ot pass.

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
marcus_sommer

It depends on how the parameter/variable is defined and called - both needs to be adjusted to each other. By defining the parameter like: $(v(Actual)) the call must be: '$1' - not mandatory within a set analysis because they expect a string and it's only necessary if the string contains spaces or special chars - but by using: $(v('Actual')) the call could be just $1.