<?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: How to fill a column with values based on other columns? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-fill-a-column-with-values-based-on-other-columns/m-p/1647334#M731441</link>
    <description>&lt;P&gt;Hi, are you sure the error is because of that row of code? it only shows one parameter for sum.&lt;/P&gt;&lt;P&gt;You can try with rangesum if you need to add more than one field.&lt;/P&gt;&lt;P&gt;Or upload a sample so we can take a look.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2019 08:10:00 GMT</pubDate>
    <dc:creator>rubenmarin</dc:creator>
    <dc:date>2019-11-15T08:10:00Z</dc:date>
    <item>
      <title>How to fill a column with values based on other columns?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-fill-a-column-with-values-based-on-other-columns/m-p/1647246#M731440</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table where I'd like to create a set of derived columns based on columns but I'm having a lot of difficulty with coding the logic. Any help would be highly appreciated!&lt;/P&gt;&lt;P&gt;Suppose my current table is such that:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Current table:&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product Type&lt;/TD&gt;&lt;TD&gt;Fruit&lt;/TD&gt;&lt;TD&gt;Color&lt;/TD&gt;&lt;TD&gt;Color Known?&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Individual Color&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Individual&lt;/TD&gt;&lt;TD&gt;Apple&lt;/TD&gt;&lt;TD&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lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Basket&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, suppose fruit is being sold two ways: individually vs. combined in a basket. We want to be able to calculate the number of fruit associated with each color, with drill-down into type. If fruit is being sold individually, we either know or do not know the color. If known, we can designate the color in the "Individual Color" column. If unknown (i.e. Color Known? = N), then we can assume the color distribution based on the distribution of same fruit type in a basket and then allocate to each color.&lt;/P&gt;&lt;P&gt;For example, we do not know the color of individual apples but know that a basket of apples being sold contains 1 Red, 3 Yellow, and 2 Green (i.e. total 6 apples). In other words, in the basket, 17% is Red (1/6), 50% is Yellow (3/6), and 33% (2/6) is Green. Applied to the individual apples (total 4), we can assume there are 0.7 Red apples (4 * 0.17), 2 Yellow apples (4 * 0.5), and 1.3 Green apples (4 * 0.33). Assume decimals are allowed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a result our final table should look like the below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Final data table&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Product Type&lt;/TD&gt;&lt;TD&gt;Fruit&lt;/TD&gt;&lt;TD&gt;Color&lt;/TD&gt;&lt;TD&gt;Final Color&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;TD&gt;Final Count&lt;/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/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Basket&lt;/TD&gt;&lt;TD&gt;Apple&lt;/TD&gt;&lt;TD&gt;Green&lt;/TD&gt;&lt;TD&gt;Green&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Basket&lt;/TD&gt;&lt;TD&gt;Grapes&lt;/TD&gt;&lt;TD&gt;Green&lt;/TD&gt;&lt;TD&gt;Green&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Basket&lt;/TD&gt;&lt;TD&gt;Grapes&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;TD&gt;Red&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Basket&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;Orange&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In doing so, I can then build a chart with dimensions Final Color and Fruit to get the total # of fruit for each color.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to implement these during the Load script. I am trying to get the Final Color logic such that:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if Product Type = Basket then Final Color = Color&lt;/LI&gt;&lt;LI&gt;if Product Type = Individual then Final Color = same as Color when Product Type = Basket&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Likewise, Final Count column logic should be:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if Product Type = Basket then Final Count = Count&lt;/LI&gt;&lt;LI&gt;if Product Type = Individual then Final Count = Individual Color Count * Distribution of Color under Basket&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For Final Count, I tried creating an intermediary column in the load such that:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Load * ,

sum(Total &amp;lt;[Product Type], [Fruit], [Color]&amp;gt; [Count]) as [Calculation1]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I ran into an error saying that Sum only allows 1 parameter even though the sum formula works fine as an expression when creating a table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 01:56:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-fill-a-column-with-values-based-on-other-columns/m-p/1647246#M731440</guid>
      <dc:creator>lalacloudvisuals</dc:creator>
      <dc:date>2024-11-16T01:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill a column with values based on other columns?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-fill-a-column-with-values-based-on-other-columns/m-p/1647334#M731441</link>
      <description>&lt;P&gt;Hi, are you sure the error is because of that row of code? it only shows one parameter for sum.&lt;/P&gt;&lt;P&gt;You can try with rangesum if you need to add more than one field.&lt;/P&gt;&lt;P&gt;Or upload a sample so we can take a look.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 08:10:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-fill-a-column-with-values-based-on-other-columns/m-p/1647334#M731441</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2019-11-15T08:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill a column with values based on other columns?</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-fill-a-column-with-values-based-on-other-columns/m-p/1648671#M731442</link>
      <description>&lt;P&gt;Here is the Help link for Sum as used in the Script, which is potentially different than what is allowed in an Expression, so be sure to compare things:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/sum.htm" target="_blank"&gt;https://help.qlik.com/en-US/qlikview/April2019/Subsystems/Client/Content/QV_QlikView/Scripting/AggregationFunctions/sum.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I agree with Ruben otherwise, you likely will have to attach a sample app etc. in order for folks to be able to help further, as this is one of those where you likely need to see a lot more in order to try to figure out what is going wrong.&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2019 16:47:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-fill-a-column-with-values-based-on-other-columns/m-p/1648671#M731442</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2019-11-19T16:47:56Z</dc:date>
    </item>
  </channel>
</rss>

