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: 
Not applicable

Set Analysis based on condition

Hi,

I'm trying to use a variable to control a set analysis operation.

Currently my variable vSetPortfolio contains the expression

%Key_MatterPartner={'$(=Only(UserKey))'}

What I'd like to do is instead of always setting %Key_MatterPartner, is conditionally set either %Key_MatterPartner or another field %Key_MatterExec based on the selected value in my Rank field. So, if Rank is 'Partner' use %Key_MatterPartner={'$(=Only(UserKey))'} otherwise use %Key_MatterExec={'$(=Only(UserKey))'}

So far I have tried this:

if(Rank='Partner',%Key_MatterPartner={'$(=Only(UserKey))'},%Key_MatterExec={'$(=Only(UserKey))'})

however this seems to set both %Key_MatterPartner AND %KeyMatterExec at the same time.

Help!

Marcus

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Marcus and welcome to the Forums,

As you already have a variable for each case, you may add in your set analysis a new variable (say, vSetAnalysis) which is populated with one of the existing, based on a selected field, triggered by a button or something:

Sum({< $(vSetAnalysis) >} Amount)


where vSetAnalysis will have

%Key_MatterPartner = {'$(=Only(UserKey))'}


Hope that helps

View solution in original post

2 Replies
Miguel_Angel_Baeyens

Hello Marcus and welcome to the Forums,

As you already have a variable for each case, you may add in your set analysis a new variable (say, vSetAnalysis) which is populated with one of the existing, based on a selected field, triggered by a button or something:

Sum({< $(vSetAnalysis) >} Amount)


where vSetAnalysis will have

%Key_MatterPartner = {'$(=Only(UserKey))'}


Hope that helps

Not applicable
Author

Hi Miguel,

thanks for your help.

What I tried was setting up two variables to contain each of my conditions,

so:
vSetPartnerPortfolio = %Key_MatterPartner={'$(=Only(UserKey))'}
vSetAssociatePortfolio = %Key_MatterExec={'$(=Only(UserKey))'}

Then a macro to set a third variable to one of these dependant on the users' rank.

set rank = ActiveDocument.Fields("Rank").GetOptionalValues

set vSetPortfolio = ActiveDocument.GetVariable("vSetPortfolio")
set vSetAssociatePortfolio = ActiveDocument.GetVariable("vSetAssociatePortfolio")
set vSetPartnerPortfolio = ActiveDocument.GetVariable("vSetPartnerPortfolio")

if rank.count=1 and rank.item(0).Text = "Associate" then
vSetPortfolio.SetContent vSetAssociatePortfolio.GetContent.String, true
else
vSetPortfolio.SetContent vSetPartnerPortfolio.GetContent.String, true
end if

Not quite as elegant as I was hoping, my preference would have been just to have an if condition in my vSetPortfolio variable, but it seems to work just fine.

Marcus