<?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 Re: How to use a parameter in a variable to use an alternate state in set analysis in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-use-a-parameter-in-a-variable-to-use-an-alternate-state/m-p/1201243#M875758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following syntax ist working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set fTotalDuration=(sum({$1} Duration)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the diagrams you can use the formular like &lt;EM&gt;=$(fTotalDuration('Machine1')).&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;'Machine1'&lt;/EM&gt; is the defined alternate state.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dirk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 May 2017 14:06:46 GMT</pubDate>
    <dc:creator />
    <dc:date>2017-05-08T14:06:46Z</dc:date>
    <item>
      <title>How to use a parameter in a variable to use an alternate state in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-a-parameter-in-a-variable-to-use-an-alternate-state/m-p/1201241#M875756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have read about alternate states, variables and parameters. But I have diffuculties in the correct use. The following is an example, the real formulas are more complex.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have defined a variable with a formula that uses set analysis: &lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;set vPossibleTime1=sum(duration)-sum({$&amp;lt;reason={1,2}&amp;gt;}duration);&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This formula is used on seperate sheets like &lt;SPAN style="; color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime1)&lt;/EM&gt;&lt;/SPAN&gt; , but there will be different alternate states in the sheets, e.g: state1 and state2.&lt;/P&gt;&lt;P&gt;The charts on the sheets are set to one of these alternate states in the properties dialogue.&amp;nbsp; When I use the alternates the set analysis does not&amp;nbsp; include the alternate state even if it is set in the properties. So I have to extend the formula:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;set vPossibleTime2=sum({&lt;SPAN style="color: #ff0000;"&gt;[state1]&lt;/SPAN&gt;}duration)-sum({&lt;SPAN style="color: #ff0000;"&gt;[state1]&lt;/SPAN&gt;&amp;lt;reason={1,2}&amp;gt;}duration);&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So this works now for one sheet, for the other sheets I cannot use it because the alternate state is fixed in the formula.&lt;/P&gt;&lt;P&gt;No I tried to use a parameter in the definition of the variable:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;set vPossibleTime3=sum({&lt;SPAN style="color: #ff0000;"&gt;$1&lt;/SPAN&gt;}duration)-sum({&lt;SPAN style="color: #ff0000;"&gt;$1&lt;/SPAN&gt;&amp;lt;reason={1,2}&amp;gt;}duration);&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After several trial and errors I found out that I now can use a formula like &lt;SPAN style="; color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;('$')&lt;/SPAN&gt;) &lt;SPAN style="color: #000000;"&gt;, &lt;SPAN style="; color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;('state1')&lt;/SPAN&gt;) &lt;SPAN style="color: #000000;"&gt;&lt;SPAN style="color: #575757;"&gt;or&lt;/SPAN&gt; &lt;SPAN style="; color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;('state2')&lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000080;"&gt;&lt;EM&gt;) &lt;SPAN style="color: #575757;"&gt;in the different sheets.&lt;/SPAN&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #008000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #575757;"&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #008000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #575757;"&gt;&lt;EM&gt;I expected a formula like &lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;('&lt;SPAN style="color: #ff0000;"&gt;[&lt;/SPAN&gt;state2&lt;SPAN style="color: #ff0000;"&gt;]&lt;/SPAN&gt;')&lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000080;"&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&amp;nbsp; but &lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #575757;"&gt;this does not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;Now I want to now if this is the correct syntax:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN style="color: #575757;"&gt;Defining the variable: &lt;/SPAN&gt;&lt;SPAN style="color: #575757;"&gt;&lt;EM&gt;set vPossibleTime3=sum&lt;/EM&gt;&lt;/SPAN&gt;&lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #008000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #575757;"&gt;&lt;EM&gt;&lt;EM&gt;({&lt;SPAN style="color: #ff0000;"&gt;$1&lt;/SPAN&gt;}duration)-sum({&lt;SPAN style="color: #ff0000;"&gt;$1&lt;/SPAN&gt;&amp;lt;reason={1,2}&amp;gt;}duration);&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #575757;"&gt;using the variable in a formula:&lt;/SPAN&gt;&lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #008000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #575757;"&gt;&lt;EM&gt;&lt;EM&gt; &lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;('state1')&lt;/SPAN&gt;)&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthermore I have some nested formulas, i.d. one formula with parameters is used in the other like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;set vAvailableTime1 = $(vPossibleTime1)-sum({$&amp;lt;reason={3,4}&amp;gt;}duration)&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;together with the Parameters this looks like:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;set vAvailableTime2 = &lt;SPAN style="; color: #000000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #008000;"&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #575757;"&gt;&lt;EM&gt;&lt;EM style=": ; color: #000000;"&gt;&lt;EM style=": ; color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;(&lt;SPAN style="color: #ff0000;"&gt;&lt;EM&gt;$1&lt;/EM&gt;&lt;/SPAN&gt;)&lt;/SPAN&gt;)&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;-sum({&lt;SPAN style="color: #ff0000;"&gt;$1&lt;/SPAN&gt;&amp;lt;reason={3,4}&amp;gt;}duration)&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With this I can use a formula like &lt;EM&gt;&lt;SPAN style="color: #000080;"&gt;$(vAvailableTime2&lt;/SPAN&gt;&lt;SPAN style="color: #008000;"&gt;('state2')&lt;/SPAN&gt;&lt;SPAN style="color: #000080;"&gt;)&lt;/SPAN&gt;&lt;/EM&gt; in the sheets. In the tests it seems to work.&lt;/P&gt;&lt;P&gt;But before I change the formula in all sheets I want to make sure that this is the correct procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Who can answer this question?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dirk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-a-parameter-in-a-variable-to-use-an-alternate-state/m-p/1201241#M875756</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a parameter in a variable to use an alternate state in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-a-parameter-in-a-variable-to-use-an-alternate-state/m-p/1201242#M875757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your approach should work. I'm not absolutely sure how alternate states will be handled as parameter within variables but I assume the same like by fieldnames and this meant you don't need single-quotes to references them. This meant: &lt;SPAN style="color: #000000;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #008000;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #575757;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;(&lt;SPAN style="color: #ff0000;"&gt;[&lt;/SPAN&gt;state2&lt;SPAN style="color: #ff0000;"&gt;]&lt;/SPAN&gt;)&lt;SPAN style="color: #000000;"&gt;&lt;EM style="color: #000080;"&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt; and &lt;SPAN style="color: #000000;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #008000;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #575757;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #000000;"&gt;&lt;EM style="color: #000080;"&gt;&lt;EM&gt;$(vPossibleTime3&lt;SPAN style="color: #008000;"&gt;(state2)&lt;SPAN style="color: #000000;"&gt;&lt;EM style="color: #000080;"&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/SPAN&gt; should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beside them I think you could simplify your variable-expression from:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set vPossibleTime1=sum(duration)-sum({$&amp;lt;reason={1,2}&amp;gt;}duration);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;set vPossibleTime1=sum({$&amp;lt;reason &lt;STRONG&gt;-=&lt;/STRONG&gt; {1,2}&amp;gt;}duration);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Further it might be useful to replace the reason-values of {1,2} or {3,4} also with a parameter whereby the use of a comma-list within a variable-parameter is problematic - but in some cases it worked, see for example: &lt;A href="https://community.qlik.com/message/1148666"&gt;Re: Aggr with Two parameter Variable not working&lt;/A&gt;‌.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2016 17:28:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-a-parameter-in-a-variable-to-use-an-alternate-state/m-p/1201242#M875757</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2016-11-02T17:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a parameter in a variable to use an alternate state in set analysis</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-use-a-parameter-in-a-variable-to-use-an-alternate-state/m-p/1201243#M875758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following syntax ist working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set fTotalDuration=(sum({$1} Duration)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the diagrams you can use the formular like &lt;EM&gt;=$(fTotalDuration('Machine1')).&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;'Machine1'&lt;/EM&gt; is the defined alternate state.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dirk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 May 2017 14:06:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-use-a-parameter-in-a-variable-to-use-an-alternate-state/m-p/1201243#M875758</guid>
      <dc:creator />
      <dc:date>2017-05-08T14:06:46Z</dc:date>
    </item>
  </channel>
</rss>

