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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
ruben_moya
Creator
Creator

Add condition to a variable attached in a file

Hi experts!

I haven't been able to find a solution to my issue on previous post. 

I was wondering if there is any way to add a condition in set analysis to a variable that has already been defined. 

Ie:

I am using the variable 'vSalesCountry' in a KPI. The variable has been defined and attached in an excel file:

Sum({<$(vExample), Flag_Country ={1}>}Sales)

Then I realise I would need to use the same variable 'vSalesCountry' but adding a new condition (Ie: Flag_User={1})

-Do I have to create a new variable in my excel file such as Sum({<$(vExample), Flag_Country ={1}, Flag_User={1}>}Sales)?

-Is there any way  in set analysis that I could add a new filter and reuse the variable 'vSalesCountry'

 

I hope I explained myself clearly,still  a newbie!

Thanks a lot in advance

 

 

 

 

 

1 Solution

Accepted Solutions
marcus_sommer

It's called parametrized variable and it might in your case look like:

Sum({<$(vExample), Flag_Country ={$1}, Flag_User={$2}>}Sales)

and your call could be:

$(vSalesCountry(1, 1)) or $(vSalesCountry(1, '*'))

- Marcus

View solution in original post

4 Replies
OmarBenSalem

don't create variables as follow:

 

vVariable=       sum({<field1={...},field2={...}>}Sales)

 

but as folllow : field1={...},field2={...}

 

With this, u can use the variable in ur expression:

 

sum({<$(vVariable)>}Sales)

if u want to add yet another conditon:

sum({<$(vVariable),Flag={1}>}Sales)

Hope that was clear

ruben_moya
Creator
Creator
Author

Hi Omar, thanks a lot for your qlik reply,

I don't think I explained myself clearly. sorry about that. l will redo my question again:
What i would need to do is to change the value in set analysis of a field included in a variable already defined:
Actually, Once i saw something similar but I can't remember how was it exactly:
vExample= Sum({<Flag_User={1}, Flag_Country ={$}>}Sales)
---
Calling the variable in set analysis:
vExample(2) ---> result: Sum({<Flag_User={1}, Flag_Country ={2}>}Sales)

Does it sound familiar to anyone?

Thanks!!





marcus_sommer

It's called parametrized variable and it might in your case look like:

Sum({<$(vExample), Flag_Country ={$1}, Flag_User={$2}>}Sales)

and your call could be:

$(vSalesCountry(1, 1)) or $(vSalesCountry(1, '*'))

- Marcus

ruben_moya
Creator
Creator
Author

Thanks a lot guys and sorry for the first message, wasn't really clear.