<?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: Copy Selections from one field to another in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Copy-Selections-from-one-field-to-another/m-p/614489#M226698</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Christof,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;That is excellent&lt;/STRONG&gt;. Why not create a document? Rather than a discussion that will be "forgotten" in few days ? In other words, is is the right place ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did not know the trick with &lt;STRONG&gt;aggr&lt;/STRONG&gt;().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fabrice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Mar 2014 15:15:59 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-03-07T15:15:59Z</dc:date>
    <item>
      <title>Copy Selections from one field to another</title>
      <link>https://community.qlik.com/t5/QlikView/Copy-Selections-from-one-field-to-another/m-p/614488#M226697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I often hear from QV Designers that they want to transfer a selection from one field to another (provided that those two fields have the same values in common). Or similary, to transfer the selections of just one given field from one state to another.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both is possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a simple and readable approach which is good to transfer just a couple of dimension values ... and there is a formula to transfer even millions of selections in a second or so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Assuming you have a field named "FieldCopyFrom" and a field called "FieldCopyTo" (replace this with something out of your model)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #008000; font-size: 14pt;"&gt;&lt;STRONG&gt;COPYING JUST A FEW SELECTIONS FROM ONE FIELD TO ANOTHER&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The syntax to set (a small number of) multiple values into a field is this&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; border-image: none; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="padding: 2px; text-align: center;"&gt;&lt;STRONG&gt;(value1|value2|valueN)&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Separate values with Pipe | and put brackets around. However, this syntax supports wildcards (that's good) but does not support spaces in the values (that's bad). But if you put a single-character wildcard "?" instead of a space " " you can achieve very likely the desired results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;STRONG&gt;(Christof?Schwarz|Abraham?Lincoln|Jimmy?Hendrix)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way, the same syntax is supported anywhere in the frontend when you type to search for fields! Use * and/or ? wildcards, the pipe acts like an OR. Below example means: All codes containing the combination UT or SA:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;IMG __jive_id="54518" alt="" class="jiveImage" src="https://community.qlik.com/legacyfs/online/54518_pastedImage_8.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To produce this by an Action (Button, Textbox) put the following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="54519" alt="" class="jiveImage" height="292" src="https://community.qlik.com/legacyfs/online/54519_pastedImage_14.png" style="width: 470px; height: 291.855px; display: block; margin-left: auto; margin-right: auto;" width="470" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;Value: &lt;SPAN style="; color: #0000ff;"&gt;&lt;STRONG&gt;='(' &amp;amp; Concat(DISTINCT Replace(FieldCopyFrom,' ','?'), '|') &amp;amp; ')'&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #008000; font-size: 14pt;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #008000; font-size: 14pt;"&gt;&lt;STRONG&gt;COPYING MASS SELECTIONS FROM ONE FIELD TO ANOTHER&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the AGGR Function with one dimension to create a on-demand cube (a "vector" of values), and pass this to the target field. The AGGR function has the dimension "FieldCopyTo" and the simpliest Aggregation function Only() with a set-modifier inside. The set operation is the key here: &amp;lt;FieldCopyTo=P(FieldCopyFrom)&amp;gt; .... the rest is nerd syntax &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="54521" alt="" class="jiveImage" src="https://community.qlik.com/legacyfs/online/54521_pastedImage_29.png" style="width: auto; height: auto; display: block; margin-left: auto; margin-right: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only disadvantage is, that the FieldCopyTo will only further narrow down the selection if you do not reset the selection first. So you should put &lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;two actions&lt;/STRONG&gt;&lt;/SPAN&gt;: "Clear Selection" of field "FieldCopyTo" first and &lt;SPAN style="text-decoration: underline;"&gt;then&lt;/SPAN&gt; this action:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field: &lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;=If(GetSelectedCount(FieldCopyFrom), 'FieldCopyTo')&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Value: &lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;='=FieldCopyTo=Aggr(Only({&amp;lt;FieldCopyTo=P(FieldCopyFrom)&amp;gt;} FieldCopyTo), FieldCopyTo)'&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The If(GetSelectedCount(..)) condition is good to check, if there was any selection made in FieldCopyFrom. If you don't check this and the action executes, you will see all values selected in FieldCopyTo even when nothing was selected in FieldCopyFrom.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;IMG __jive_id="54524" alt="" class="jiveImage" height="286" src="https://community.qlik.com/legacyfs/online/54524_pastedImage_2.png" style="width: 440px; height: 286px;" width="440" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #008000; font-size: 14pt;"&gt;&lt;STRONG&gt;COPYING SELECTIONS OF ONE FIELD FROM ONE ALTERNATE STATE TO ANOTHER&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="; color: #008000; font-size: 14pt;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The approach and the syntax to copy the selections of just a single field from one state to another is similar to the above with a slightly adopted syntax, as two different alternate states are now involved and the field name is (assumed) to be the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you copy from the main state into an alternate state, this is the syntax (the essetial part herein is &lt;STRONG&gt;$::CopyField&lt;/STRONG&gt; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="54527" alt="" class="jiveImage" src="https://community.qlik.com/legacyfs/online/54527_pastedImage_37.png" style="display: block; margin-left: auto; margin-right: auto; width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Value:&lt;STRONG style="color: #0000ff;"&gt;='=CopyField=Aggr(Only({&amp;lt;CopyField=P($::CopyField)&amp;gt;} CopyField), CopyField)'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;If you copy from an alternate state to another, this is the syntax (the essetial part herein is &lt;STRONG&gt;[SourceState]::CopyField&lt;/STRONG&gt; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Value:&lt;STRONG style="color: #0000ff;"&gt;='=CopyField=Aggr(Only({&amp;lt;CopyField=P([SourceState]::CopyField)&amp;gt;} CopyField), CopyField)'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" style="max-width: 1200px; max-height: 900px; display: block; margin-left: auto; margin-right: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Don't forget: Start the action block with a "Clear Field" action first, as otherwise the selection of that "=Aggr..." function can only make the previous selection more narrow but not wider!&lt;/P&gt;&lt;P&gt;Both Actions need to be set to work in the "TargetState", in my case "State2"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="54529" alt="" class="jiveImage" height="270" src="https://community.qlik.com/legacyfs/online/54529_pastedImage_52.png" style="width: 466px; height: 269.829px; display: block; margin-left: auto; margin-right: auto;" width="466" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't want the user to wonder about the strange formula in the "Current Selection Box" and to start questioning which drugs you took to write it, put a third action after this: "Select Possible". This will resolve the formula into somehing like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="54530" alt="" class="jiveImage" src="https://community.qlik.com/legacyfs/online/54530_pastedImage_61.png" style="width: auto; height: auto; display: block; margin-left: auto; margin-right: auto;" /&gt;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Feel free to download the my attached example, where all this code is presented and can be tested&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Enjoy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Christof Schwarz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2014 14:47:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Copy-Selections-from-one-field-to-another/m-p/614488#M226697</guid>
      <dc:creator>ChristofSchwarz</dc:creator>
      <dc:date>2014-03-07T14:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Selections from one field to another</title>
      <link>https://community.qlik.com/t5/QlikView/Copy-Selections-from-one-field-to-another/m-p/614489#M226698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Christof,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;That is excellent&lt;/STRONG&gt;. Why not create a document? Rather than a discussion that will be "forgotten" in few days ? In other words, is is the right place ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did not know the trick with &lt;STRONG&gt;aggr&lt;/STRONG&gt;().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fabrice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2014 15:15:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Copy-Selections-from-one-field-to-another/m-p/614489#M226698</guid>
      <dc:creator />
      <dc:date>2014-03-07T15:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Selections from one field to another</title>
      <link>https://community.qlik.com/t5/QlikView/Copy-Selections-from-one-field-to-another/m-p/614490#M226699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Good. Point. I don’t know how the “document” section is organized. I keep creating posts in the default area and this is “discussion” … &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif'; color: #1f497d;"&gt;Can I still move this content?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2014 15:51:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Copy-Selections-from-one-field-to-another/m-p/614490#M226699</guid>
      <dc:creator>ChristofSchwarz</dc:creator>
      <dc:date>2014-03-07T15:51:13Z</dc:date>
    </item>
  </channel>
</rss>

