<?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 - using variable as fieldname in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Analysis-using-variable-as-fieldname/m-p/1124686#M370333</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a field called "_Dimensions" which I use to select different measure fields with the "always one selected value" option.&lt;/P&gt;&lt;P&gt;In a variable I have if-statements to call the sum function.&lt;/P&gt;&lt;P&gt;This is the original version:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14714335955967895 jive_text_macro" jivemacro_uid="_14714335955967895" modifiedtitle="true"&gt;
&lt;P&gt;if(SubStringCount(Concat(_Dimensions, '|'), 'This is A'), sum([This_Is_Field_A]),&lt;/P&gt;
&lt;P&gt;if(SubStringCount(Concat(_Dimensions, '|'), 'This is B'), sum([This_Is_Field_B]),&lt;/P&gt;
&lt;P&gt;if(SubStringCount(Concat(_Dimensions, '|'), 'This is C'), sum([This_Is_Field_C]),Null()&lt;/P&gt;
&lt;P&gt;)))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can use this in a "normal" expression, however now I want to be able to write something like this:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14714340595672141" jivemacro_uid="_14714340595672141" modifiedtitle="true"&gt;
&lt;P&gt;=sum({$&amp;lt;[MyDimension]={"SomeFilter"}&amp;gt;} GetFieldSelections(_Dimensions))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that I can grab the currently selected text in the _Dimensions field dynamically and use it in the sum function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note that above field names and selection strings a written differently.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know what I need to do to get this right?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Aug 2016 11:50:30 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-08-17T11:50:30Z</dc:date>
    <item>
      <title>Set Analysis - using variable as fieldname</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-using-variable-as-fieldname/m-p/1124686#M370333</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a field called "_Dimensions" which I use to select different measure fields with the "always one selected value" option.&lt;/P&gt;&lt;P&gt;In a variable I have if-statements to call the sum function.&lt;/P&gt;&lt;P&gt;This is the original version:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14714335955967895 jive_text_macro" jivemacro_uid="_14714335955967895" modifiedtitle="true"&gt;
&lt;P&gt;if(SubStringCount(Concat(_Dimensions, '|'), 'This is A'), sum([This_Is_Field_A]),&lt;/P&gt;
&lt;P&gt;if(SubStringCount(Concat(_Dimensions, '|'), 'This is B'), sum([This_Is_Field_B]),&lt;/P&gt;
&lt;P&gt;if(SubStringCount(Concat(_Dimensions, '|'), 'This is C'), sum([This_Is_Field_C]),Null()&lt;/P&gt;
&lt;P&gt;)))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can use this in a "normal" expression, however now I want to be able to write something like this:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14714340595672141" jivemacro_uid="_14714340595672141" modifiedtitle="true"&gt;
&lt;P&gt;=sum({$&amp;lt;[MyDimension]={"SomeFilter"}&amp;gt;} GetFieldSelections(_Dimensions))&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that I can grab the currently selected text in the _Dimensions field dynamically and use it in the sum function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note that above field names and selection strings a written differently.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know what I need to do to get this right?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2016 11:50:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-using-variable-as-fieldname/m-p/1124686#M370333</guid>
      <dc:creator />
      <dc:date>2016-08-17T11:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis - using variable as fieldname</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-using-variable-as-fieldname/m-p/1124687#M370334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=sum({$&amp;lt;[MyDimension]={"SomeFilter"}&amp;gt;} &lt;STRONG&gt;[$(=GetFieldSelections(_Dimensions))]&lt;/STRONG&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, 17 Aug 2016 12:00:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-using-variable-as-fieldname/m-p/1124687#M370334</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2016-08-17T12:00:01Z</dc:date>
    </item>
  </channel>
</rss>

