<?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 Expression - Multiple GetFieldSelections() in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Expression-Multiple-GetFieldSelections/m-p/1796139#M1211237</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I was wondering if anyone would be able to help me with the following issue.&lt;/P&gt;&lt;P&gt;I am trying to write an expression using set analysis that will return records based on selected date field values.&lt;/P&gt;&lt;P&gt;Here is the expression I wrote:&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;count({$&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;lt;[Sale Close Year]=&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;,[Purchase Year]={'$(=getFieldSelections([Sale Close Year]))'}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;,[Purchase Quarter]={'$(=getFieldSelections([Sale Close Quarter]))'}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;,[Purchase Month]={'$(=getFieldSelections([Sale Close Month]))'}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;[CUST_ACCT_NB])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;(Note: I use '[Sale Close Year ]=' to exclude this filter from my result set, this is because I am counting Purchase records that have a [Purchase Year] that falls into the same year as the selected [Sale Close Year ]&amp;nbsp; but its associated&amp;nbsp; [Sale Close Year] falls into a different year....&amp;nbsp; due to timing issues in record processing.)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The expression above works if only one of each date field component is selected.&lt;BR /&gt;However, it is possible for a user to select multiple values for any of these date fields: [Sale Close Year],[Sale Close Quarter],[Sale Close Month]&lt;BR /&gt;I need to write an expression that can handle any selection combination.&lt;/P&gt;&lt;P&gt;Here is an image of the selection filters:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yi0ta4_0-1617212238032.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/52198i60C2EACE8947EBB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yi0ta4_0-1617212238032.png" alt="Yi0ta4_0-1617212238032.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the expression changes needed should apply to all of the date field components, lets simplify the problem by looking at just one of the fields,&amp;nbsp; [Sale Close Month] for example.&lt;/P&gt;&lt;P&gt;This expression works if only one [Sale Close Month] is selected:&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;[Purchase Month]={'$(=getFieldSelections([Sale Close Month]))'}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;To test this, I wrote the following expression in a text box:&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;=if(GetSelectedCount([Sale Close Month])&amp;gt;0,getFieldSelections([Sale Close Month]))&lt;/FONT&gt;&lt;BR /&gt;It returns:&lt;BR /&gt;Jan,Feb,Mar&lt;BR /&gt;So I am assuming that is what the getFieldSelections function is returning.&lt;BR /&gt;&lt;FONT color="#993366"&gt;(Note: I use the conditional expression to check to see if the user has made a selection on this field, and handle it if that check is true.)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Since these are string values I know I will have to quote each one, so I wrote:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;=if(GetSelectedCount([Sale Close Month])&amp;gt;0,chr(39) &amp;amp; getFieldSelections([Sale Close Month]) &amp;amp; chr(39))&lt;/FONT&gt;&lt;BR /&gt;But this returns:&lt;BR /&gt;'Jan,Feb,Mar'&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;1.) Do any of you know of a way to quote each value selected?&lt;BR /&gt;2.) If so, how would I incorporate the modification into my original expression so it works in the count function?&lt;BR /&gt;(I get confused on whether to place modifications within the single quotes, or outside of them.)&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;Example:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;[Purchase Month]={'chr(39) &amp;amp; $(=getFieldSelections([Sale Close Month])) &amp;amp; chr(39)'}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;vs.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;[Purchase Month]={chr(39) &amp;amp; '$(=getFieldSelections([Sale Close Month]))' &amp;amp; chr(39)}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;Neither of these work.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thanks in advance for any help you can provide!&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Mar 2021 17:41:09 GMT</pubDate>
    <dc:creator>Yi0ta4</dc:creator>
    <dc:date>2021-03-31T17:41:09Z</dc:date>
    <item>
      <title>Set Analysis Expression - Multiple GetFieldSelections()</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Expression-Multiple-GetFieldSelections/m-p/1796139#M1211237</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I was wondering if anyone would be able to help me with the following issue.&lt;/P&gt;&lt;P&gt;I am trying to write an expression using set analysis that will return records based on selected date field values.&lt;/P&gt;&lt;P&gt;Here is the expression I wrote:&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;count({$&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;lt;[Sale Close Year]=&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;,[Purchase Year]={'$(=getFieldSelections([Sale Close Year]))'}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;,[Purchase Quarter]={'$(=getFieldSelections([Sale Close Quarter]))'}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;,[Purchase Month]={'$(=getFieldSelections([Sale Close Month]))'}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;[CUST_ACCT_NB])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993366"&gt;(Note: I use '[Sale Close Year ]=' to exclude this filter from my result set, this is because I am counting Purchase records that have a [Purchase Year] that falls into the same year as the selected [Sale Close Year ]&amp;nbsp; but its associated&amp;nbsp; [Sale Close Year] falls into a different year....&amp;nbsp; due to timing issues in record processing.)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The expression above works if only one of each date field component is selected.&lt;BR /&gt;However, it is possible for a user to select multiple values for any of these date fields: [Sale Close Year],[Sale Close Quarter],[Sale Close Month]&lt;BR /&gt;I need to write an expression that can handle any selection combination.&lt;/P&gt;&lt;P&gt;Here is an image of the selection filters:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Yi0ta4_0-1617212238032.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/52198i60C2EACE8947EBB5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Yi0ta4_0-1617212238032.png" alt="Yi0ta4_0-1617212238032.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the expression changes needed should apply to all of the date field components, lets simplify the problem by looking at just one of the fields,&amp;nbsp; [Sale Close Month] for example.&lt;/P&gt;&lt;P&gt;This expression works if only one [Sale Close Month] is selected:&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;[Purchase Month]={'$(=getFieldSelections([Sale Close Month]))'}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;To test this, I wrote the following expression in a text box:&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;=if(GetSelectedCount([Sale Close Month])&amp;gt;0,getFieldSelections([Sale Close Month]))&lt;/FONT&gt;&lt;BR /&gt;It returns:&lt;BR /&gt;Jan,Feb,Mar&lt;BR /&gt;So I am assuming that is what the getFieldSelections function is returning.&lt;BR /&gt;&lt;FONT color="#993366"&gt;(Note: I use the conditional expression to check to see if the user has made a selection on this field, and handle it if that check is true.)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Since these are string values I know I will have to quote each one, so I wrote:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;=if(GetSelectedCount([Sale Close Month])&amp;gt;0,chr(39) &amp;amp; getFieldSelections([Sale Close Month]) &amp;amp; chr(39))&lt;/FONT&gt;&lt;BR /&gt;But this returns:&lt;BR /&gt;'Jan,Feb,Mar'&lt;/P&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;1.) Do any of you know of a way to quote each value selected?&lt;BR /&gt;2.) If so, how would I incorporate the modification into my original expression so it works in the count function?&lt;BR /&gt;(I get confused on whether to place modifications within the single quotes, or outside of them.)&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#800080"&gt;Example:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;[Purchase Month]={'chr(39) &amp;amp; $(=getFieldSelections([Sale Close Month])) &amp;amp; chr(39)'}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;vs.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;[Purchase Month]={chr(39) &amp;amp; '$(=getFieldSelections([Sale Close Month]))' &amp;amp; chr(39)}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080"&gt;Neither of these work.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thanks in advance for any help you can provide!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 17:41:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-Expression-Multiple-GetFieldSelections/m-p/1796139#M1211237</guid>
      <dc:creator>Yi0ta4</dc:creator>
      <dc:date>2021-03-31T17:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis Expression - Multiple GetFieldSelections()</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Expression-Multiple-GetFieldSelections/m-p/1796182#M1211245</link>
      <description>&lt;P&gt;&lt;SPAN&gt;You can something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[Purchase Year]={$(=concat(distinct chr(39)&amp;amp;[Sale Close Year]&amp;amp;chr(39),','))}&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 19:21:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-Expression-Multiple-GetFieldSelections/m-p/1796182#M1211245</guid>
      <dc:creator>GaryGiles</dc:creator>
      <dc:date>2021-03-31T19:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis Expression - Multiple GetFieldSelections()</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Expression-Multiple-GetFieldSelections/m-p/1796185#M1211247</link>
      <description>&lt;P&gt;That works perfectly... Thanks Gary!!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 19:40:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-Expression-Multiple-GetFieldSelections/m-p/1796185#M1211247</guid>
      <dc:creator>Yi0ta4</dc:creator>
      <dc:date>2021-03-31T19:40:16Z</dc:date>
    </item>
  </channel>
</rss>

