<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Set Analysis based on condition in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Analysis-based-on-condition/m-p/190250#M503180</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel,&lt;/P&gt;&lt;P&gt;thanks for your help.&lt;/P&gt;&lt;P&gt;What I tried was setting up two variables to contain each of my conditions,&lt;/P&gt;&lt;P&gt;so:&lt;BR /&gt;&lt;EM&gt;vSetPartnerPortfolio = %Key_MatterPartner={'$(=Only(UserKey))'}&lt;BR /&gt;vSetAssociatePortfolio = %Key_MatterExec={'$(=Only(UserKey))'}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then a macro to set a third variable to one of these dependant on the users' rank.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set rank = ActiveDocument.Fields("Rank").GetOptionalValues&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set vSetPortfolio = ActiveDocument.GetVariable("vSetPortfolio")&lt;BR /&gt;set vSetAssociatePortfolio = ActiveDocument.GetVariable("vSetAssociatePortfolio")&lt;BR /&gt;set vSetPartnerPortfolio = ActiveDocument.GetVariable("vSetPartnerPortfolio")&lt;BR /&gt;&lt;BR /&gt; if rank.count=1 and rank.item(0).Text = "Associate" then&lt;BR /&gt; vSetPortfolio.SetContent vSetAssociatePortfolio.GetContent.String, true&lt;BR /&gt;else&lt;BR /&gt; vSetPortfolio.SetContent vSetPartnerPortfolio.GetContent.String, true&lt;BR /&gt;end if&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Sep 2010 09:49:35 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-09-08T09:49:35Z</dc:date>
    <item>
      <title>Set Analysis based on condition</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-based-on-condition/m-p/190248#M503178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to use a variable to control a set analysis operation.&lt;/P&gt;&lt;P&gt;Currently my variable &lt;EM&gt;vSetPortfolio&lt;/EM&gt; contains the expression&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%Key_MatterPartner={'$(=Only(UserKey))'}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;What I'd like to do is instead of always setting &lt;EM&gt;%Key_MatterPartner&lt;/EM&gt;, is conditionally set either &lt;EM&gt;%Key_MatterPartner&lt;/EM&gt; or another field &lt;EM&gt;%Key_MatterExec&lt;/EM&gt; based on the selected value in my &lt;EM&gt;Rank&lt;/EM&gt; field. So, if &lt;EM&gt;Rank&lt;/EM&gt; is 'Partner' use &lt;EM&gt;%Key_MatterPartner={'$(=Only(UserKey))'}&lt;/EM&gt; otherwise use &lt;EM&gt;%Key_MatterExec={'$(=Only(UserKey))'}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;So far I have tried this:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;if(Rank='Partner',%Key_MatterPartner={'$(=Only(UserKey))'},%Key_MatterExec={'$(=Only(UserKey))'})&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;however this seems to set both &lt;EM&gt;%Key_MatterPartner&lt;/EM&gt; AND &lt;EM&gt;%KeyMatterExec&lt;/EM&gt; at the same time.&lt;/P&gt;&lt;P&gt;Help!&lt;/P&gt;&lt;P&gt;Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Sep 2010 08:54:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-based-on-condition/m-p/190248#M503178</guid>
      <dc:creator />
      <dc:date>2010-09-07T08:54:06Z</dc:date>
    </item>
    <item>
      <title>Set Analysis based on condition</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-based-on-condition/m-p/190249#M503179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Marcus and welcome to the Forums,&lt;/P&gt;&lt;P&gt;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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Sum({&amp;lt; $(vSetAnalysis) &amp;gt;} Amount)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;where vSetAnalysis will have&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;%Key_MatterPartner = {'$(=Only(UserKey))'}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Hope that helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Sep 2010 09:06:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-based-on-condition/m-p/190249#M503179</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2010-09-07T09:06:59Z</dc:date>
    </item>
    <item>
      <title>Set Analysis based on condition</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-based-on-condition/m-p/190250#M503180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel,&lt;/P&gt;&lt;P&gt;thanks for your help.&lt;/P&gt;&lt;P&gt;What I tried was setting up two variables to contain each of my conditions,&lt;/P&gt;&lt;P&gt;so:&lt;BR /&gt;&lt;EM&gt;vSetPartnerPortfolio = %Key_MatterPartner={'$(=Only(UserKey))'}&lt;BR /&gt;vSetAssociatePortfolio = %Key_MatterExec={'$(=Only(UserKey))'}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Then a macro to set a third variable to one of these dependant on the users' rank.&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set rank = ActiveDocument.Fields("Rank").GetOptionalValues&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set vSetPortfolio = ActiveDocument.GetVariable("vSetPortfolio")&lt;BR /&gt;set vSetAssociatePortfolio = ActiveDocument.GetVariable("vSetAssociatePortfolio")&lt;BR /&gt;set vSetPartnerPortfolio = ActiveDocument.GetVariable("vSetPartnerPortfolio")&lt;BR /&gt;&lt;BR /&gt; if rank.count=1 and rank.item(0).Text = "Associate" then&lt;BR /&gt; vSetPortfolio.SetContent vSetAssociatePortfolio.GetContent.String, true&lt;BR /&gt;else&lt;BR /&gt; vSetPortfolio.SetContent vSetPartnerPortfolio.GetContent.String, true&lt;BR /&gt;end if&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Sep 2010 09:49:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-based-on-condition/m-p/190250#M503180</guid>
      <dc:creator />
      <dc:date>2010-09-08T09:49:35Z</dc:date>
    </item>
  </channel>
</rss>

