<?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 Sum of a column usign dynamic variables based on other fields in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Sum-of-a-column-usign-dynamic-variables-based-on-other-fields/m-p/2102645#M90087</link>
    <description>&lt;P&gt;Hi, I have a table with these kind of data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LOAD * INLINE [
COD_DISCIPLINA,  CURSO, SERIE, CARGA_HORARIA

6DEF082,  PPP_2015, 1, 90
6DEF084,  PPP_2015, 1, 65
6DEF085,  PPP_2016, 2, 60

];&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also do have a few variables such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Let vPPP_2015_1			 	=	2 ;
Let vPPP_2015_2			 	=	1 ;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;These variables are going to be changed by the user in the app later, so they may be 1, 2, 10, etc.&lt;/P&gt;
&lt;P&gt;My goal here is to perform a SUM of the CARGA_HORARIA field multiplied by the variable that corresponds to its CURSO and SERIE values concatenated. So, for the first two lines it should multiply CARGA_HORARIA by vPPP_2015_1. For this I created a measure with the following expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUM(CARGA_HORARIA * $(=('v' &amp;amp; CURSO &amp;amp; '_' &amp;amp; SERIE)))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Using the first line as example, it should evaluate the expression to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUM(CARGA_HORARIA * $(=('vPPP_2015_1))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I noticed that it returns an error given because there are multiple values for CURSO and SERIE. If there is a single one for each, it will work smoothly, but not when there are multiple for either one of them.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Aug 2023 17:31:56 GMT</pubDate>
    <dc:creator>kazamabriel</dc:creator>
    <dc:date>2023-08-04T17:31:56Z</dc:date>
    <item>
      <title>Sum of a column usign dynamic variables based on other fields</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-a-column-usign-dynamic-variables-based-on-other-fields/m-p/2102645#M90087</link>
      <description>&lt;P&gt;Hi, I have a table with these kind of data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LOAD * INLINE [
COD_DISCIPLINA,  CURSO, SERIE, CARGA_HORARIA

6DEF082,  PPP_2015, 1, 90
6DEF084,  PPP_2015, 1, 65
6DEF085,  PPP_2016, 2, 60

];&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also do have a few variables such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Let vPPP_2015_1			 	=	2 ;
Let vPPP_2015_2			 	=	1 ;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;These variables are going to be changed by the user in the app later, so they may be 1, 2, 10, etc.&lt;/P&gt;
&lt;P&gt;My goal here is to perform a SUM of the CARGA_HORARIA field multiplied by the variable that corresponds to its CURSO and SERIE values concatenated. So, for the first two lines it should multiply CARGA_HORARIA by vPPP_2015_1. For this I created a measure with the following expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUM(CARGA_HORARIA * $(=('v' &amp;amp; CURSO &amp;amp; '_' &amp;amp; SERIE)))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Using the first line as example, it should evaluate the expression to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;SUM(CARGA_HORARIA * $(=('vPPP_2015_1))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I noticed that it returns an error given because there are multiple values for CURSO and SERIE. If there is a single one for each, it will work smoothly, but not when there are multiple for either one of them.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 17:31:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-a-column-usign-dynamic-variables-based-on-other-fields/m-p/2102645#M90087</guid>
      <dc:creator>kazamabriel</dc:creator>
      <dc:date>2023-08-04T17:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sum of a column usign dynamic variables based on other fields</title>
      <link>https://community.qlik.com/t5/App-Development/Sum-of-a-column-usign-dynamic-variables-based-on-other-fields/m-p/2103114#M90119</link>
      <description>&lt;P&gt;What do you want to do isn't possible. Because you will need a $-sign expansion to extract the various field-information and building from a valid variable/field-reference. Such $-sign expansion creates an adhoc-variable which means that they could have only one value at a time - and this is evaluated ones before the object is calculated and applied to each occurring.&lt;/P&gt;
&lt;P&gt;This means you will need a different approach, maybe applying multiple if-loops with a more or less hard-coded logic or maybe switching the variables to field-values and then doing the row-level assigning within aggr() constructs. With field-values the users couldn't apply each value but they could get a certain amount of choose able values.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 13:06:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Sum-of-a-column-usign-dynamic-variables-based-on-other-fields/m-p/2103114#M90119</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2023-08-07T13:06:17Z</dc:date>
    </item>
  </channel>
</rss>

