<?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: Script , cicle for to add rows linked to a specific field in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911543#M75128</link>
    <description>&lt;P&gt;Hello QFabian, almost.. But thanks for the try.&lt;/P&gt;
&lt;P&gt;What I would like to have in the output is only the column "Product" (and not the colum substitute from/to).&lt;BR /&gt;The column Product has to contains, in addiction of the Product already present in the fact table, also the all sub from and sub to, consequently row by row .&lt;/P&gt;
&lt;P&gt;Today, as a "temporary" workaraound (or let me call it "as a dirty solution") I tried to join as many times I decided (a bit hard coded because I decided&amp;nbsp; to join 5 times for the sub from and 5 times for the sub to) in this way:&lt;/P&gt;
&lt;P&gt;First time to the fact table (with Product A) I join left the product table to find the Sub from (that I will call "Sub from 1") and Sub to (that I will call "Sub from 1").&lt;BR /&gt;Then, I will again join the product table but this time as a key I will use the previous product "Sub from 1" and I will grab the one that I will call "Sub from 2" ....etc etc until "Sub from 5". Same workaround , with join left, for the "Sub to n" until 5.&lt;/P&gt;
&lt;P&gt;--&amp;gt; as a result I will have same fact table as before but for every row I will have five new columns Sub from and five colums Sub To (total 10 new columns). &lt;BR /&gt;Then I just have to apply a "cross table" function because I want only ONE column "Product" that contains all the new 10 columns including the original one (11 potential row instead of 1 at the starting).&lt;/P&gt;
&lt;P&gt;Main Product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Ohers&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 0 (it was real product from fact)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 1 (it was the first sub from the prod 0)&amp;nbsp; |&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 2 (it was the sec sub from the prod 1&amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 3 (it was the first sub to the prod 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;BR /&gt;etc&lt;BR /&gt;&lt;BR /&gt;Hope it is more clear now.&amp;nbsp;&lt;BR /&gt;I think it's working fine BUT &lt;BR /&gt;1) it is hard coded (I decided to do 5 left join for SUB FROM and 5 left join for SUB TO and if there are more options I will miss them now, or if there are fewer I am overloading for nothing)&lt;BR /&gt;2) maybe it exists a more clean way to do it&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Mar 2022 23:09:52 GMT</pubDate>
    <dc:creator>Bellamy</dc:creator>
    <dc:date>2022-03-29T23:09:52Z</dc:date>
    <item>
      <title>Script , cicle for to add rows linked to a specific field</title>
      <link>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911135#M75084</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;I am sorry if the title is not easy to understand, I will try to explain it here.&lt;/P&gt;
&lt;P&gt;I have a fact table in which there is a field that represent a product code that can be substituted from/to another product code.&lt;BR /&gt;Let's say this example:&lt;BR /&gt;|MAIN PRODUCT| |PRODUCT| |many other columns|&lt;BR /&gt;|Main product A| |Product 1| | .....|&lt;/P&gt;
&lt;P&gt;Now, I have another QVD in which there is |PRODUCT| |SUBSTITUTE TO PRODUCT| |SUBSTITUTE FROM PRODUCT|&lt;BR /&gt;It means that for each "Product" (second column of fact) there could be 1 or more than 1 of substitution (from, and to)&lt;BR /&gt;For example Product 1 substitute from Product 0 and substitute to Product 2.&lt;/P&gt;
&lt;P&gt;Now, in the new Fact table (let's say Fact2) I want to recreate all the combination as following:&lt;/P&gt;
&lt;P&gt;|MAIN PRODUCT| |PRODUCT| |many other columns|&lt;BR /&gt;|Main product A| |Product 1| |......|&lt;BR /&gt;|Main product A| |Product 0| |....(same values obviously of the Product 1|&lt;BR /&gt;|Main product A| |Product 2| |....(same values obviously of the Product 1&lt;/P&gt;
&lt;P&gt;Etc etc.&lt;/P&gt;
&lt;P&gt;So, basically, I would like that the rows duplicate whenever and wherever there are sub to , and sub from, of a Product.&lt;BR /&gt;If a Product have 1 sub from, 1 sub to, and for example both of these have consequently other 1 sub from and 1 sub to (example Product -1 --&amp;gt; Product 0&amp;nbsp; --&amp;gt; Product 1 (the one picked from fact tabe) --&amp;gt; Product 2 --&amp;gt; Product 3) I would like to see 5 rows (1 already existing + 4 identic rows with the only difference of "Product").&lt;/P&gt;
&lt;P&gt;I hope it could be clear, I tried to explain as much as detailed I can.&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 10:50:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911135#M75084</guid>
      <dc:creator>Bellamy</dc:creator>
      <dc:date>2022-03-29T10:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script , cicle for to add rows linked to a specific field</title>
      <link>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911536#M75126</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/160426"&gt;@Bellamy&lt;/a&gt;&amp;nbsp;, if i understood, maybe you can join your two tables. Here an example :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fact:&lt;BR /&gt;Load * INLINE [&lt;BR /&gt;MAIN PRODUCT, PRODUCT, F3, F4&lt;BR /&gt;Main product A, Product 1,,&lt;BR /&gt;Main product A, Product 2,,&lt;BR /&gt;Main product A, Product 3,,&lt;BR /&gt;Main product A, Product 4,,&lt;BR /&gt;Main product B, Product 1,,&lt;BR /&gt;Main product B, Product 2,,&lt;BR /&gt;Main product B, Product 3,,&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;join&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;Subst:&lt;BR /&gt;Load * INLINE [&lt;BR /&gt;PRODUCT, SUBSTITUTE TO PRODUCT, SUBSTITUTE FROM PRODUCT&lt;BR /&gt;Product 1, Product 0&lt;BR /&gt;Product 1, Product 2&lt;BR /&gt;Product 1, Product 3&lt;BR /&gt;Product 2, Product 7&lt;BR /&gt;Product 3, Product 8&lt;BR /&gt;Product 4, Product 9&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table Chart output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="QFabian_0-1648594214827.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/75678i840ED8E63ED48248/image-size/large?v=v2&amp;amp;px=999" role="button" title="QFabian_0-1648594214827.png" alt="QFabian_0-1648594214827.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 22:51:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911536#M75126</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2022-03-29T22:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script , cicle for to add rows linked to a specific field</title>
      <link>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911543#M75128</link>
      <description>&lt;P&gt;Hello QFabian, almost.. But thanks for the try.&lt;/P&gt;
&lt;P&gt;What I would like to have in the output is only the column "Product" (and not the colum substitute from/to).&lt;BR /&gt;The column Product has to contains, in addiction of the Product already present in the fact table, also the all sub from and sub to, consequently row by row .&lt;/P&gt;
&lt;P&gt;Today, as a "temporary" workaraound (or let me call it "as a dirty solution") I tried to join as many times I decided (a bit hard coded because I decided&amp;nbsp; to join 5 times for the sub from and 5 times for the sub to) in this way:&lt;/P&gt;
&lt;P&gt;First time to the fact table (with Product A) I join left the product table to find the Sub from (that I will call "Sub from 1") and Sub to (that I will call "Sub from 1").&lt;BR /&gt;Then, I will again join the product table but this time as a key I will use the previous product "Sub from 1" and I will grab the one that I will call "Sub from 2" ....etc etc until "Sub from 5". Same workaround , with join left, for the "Sub to n" until 5.&lt;/P&gt;
&lt;P&gt;--&amp;gt; as a result I will have same fact table as before but for every row I will have five new columns Sub from and five colums Sub To (total 10 new columns). &lt;BR /&gt;Then I just have to apply a "cross table" function because I want only ONE column "Product" that contains all the new 10 columns including the original one (11 potential row instead of 1 at the starting).&lt;/P&gt;
&lt;P&gt;Main Product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; | Product&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;| Ohers&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 0 (it was real product from fact)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 1 (it was the first sub from the prod 0)&amp;nbsp; |&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 2 (it was the sec sub from the prod 1&amp;nbsp; &amp;nbsp; &amp;nbsp;|&lt;BR /&gt;Main Product A&amp;nbsp; &amp;nbsp; &amp;nbsp; | Prod 3 (it was the first sub to the prod 0&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;BR /&gt;etc&lt;BR /&gt;&lt;BR /&gt;Hope it is more clear now.&amp;nbsp;&lt;BR /&gt;I think it's working fine BUT &lt;BR /&gt;1) it is hard coded (I decided to do 5 left join for SUB FROM and 5 left join for SUB TO and if there are more options I will miss them now, or if there are fewer I am overloading for nothing)&lt;BR /&gt;2) maybe it exists a more clean way to do it&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 23:09:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911543#M75128</guid>
      <dc:creator>Bellamy</dc:creator>
      <dc:date>2022-03-29T23:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script , cicle for to add rows linked to a specific field</title>
      <link>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911550#M75130</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/160426"&gt;@Bellamy&lt;/a&gt;&amp;nbsp; what about this example?&lt;/P&gt;
&lt;P&gt;Fact:&lt;BR /&gt;Load * INLINE [&lt;BR /&gt;MAIN PRODUCT, PRODUCT, F3, F4&lt;BR /&gt;Main product A, Product 1,,&lt;BR /&gt;Main product A, Product 2,,&lt;BR /&gt;Main product A, Product 3,,&lt;BR /&gt;Main product A, Product 4,,&lt;BR /&gt;Main product B, Product 5,,&lt;BR /&gt;Main product B, Product 6,,&lt;BR /&gt;Main product B, Product 7,,&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Subst:&lt;BR /&gt;Load * INLINE [&lt;BR /&gt;PRODUCT, SUBSTITUTE TO PRODUCT, SUBSTITUTE FROM PRODUCT&lt;BR /&gt;Product 1, Product 0&lt;BR /&gt;Product 1, Product 2&lt;BR /&gt;Product 1, Product 3&lt;BR /&gt;Product 2, Product 7&lt;BR /&gt;Product 3, Product 8&lt;BR /&gt;Product 4, Product 9&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Map_Main:&lt;BR /&gt;mapping&lt;BR /&gt;Load&lt;BR /&gt;PRODUCT,&lt;BR /&gt;[MAIN PRODUCT]&lt;BR /&gt;Resident Fact;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;concatenate(Fact)&lt;BR /&gt;Load &lt;BR /&gt;[SUBSTITUTE TO PRODUCT] as [PRODUCT],&lt;BR /&gt;applymap('Map_Main',PRODUCT) as [MAIN PRODUCT]&lt;BR /&gt;Resident Subst&lt;BR /&gt;Where not exists([MAIN PRODUCT], [SUBSTITUTE TO PRODUCT]);&lt;BR /&gt;drop table Subst;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="QFabian_0-1648601478757.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/75684iD9B38A7C5AD69C5C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="QFabian_0-1648601478757.png" alt="QFabian_0-1648601478757.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 00:52:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Script-cicle-for-to-add-rows-linked-to-a-specific-field/m-p/1911550#M75130</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2022-03-30T00:52:03Z</dc:date>
    </item>
  </channel>
</rss>

