<?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: Substract 2 fields in a loading script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763265#M719559</link>
    <description>&lt;P&gt;Thanks but I have hundreds of thousands of files in my original file so I can hardly insert a Load * Inline &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Revenues and Costs are in the same .qvd but they are 2 separate fields.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Nov 2020 13:44:28 GMT</pubDate>
    <dc:creator>arnoqlik</dc:creator>
    <dc:date>2020-11-20T13:44:28Z</dc:date>
    <item>
      <title>[SOLVED] Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762969#M719553</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'd like to substract 2 fields in my loading script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TableName:
LOAD
	Costs,
	Revenues,
	Revenues - Costs as Profits,
FROM $(vDATA)\name.qvd (qvd);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get data/numbers for Costs and Revenues but Profits is always 0.&lt;/P&gt;&lt;P&gt;Thanks in advance for your kind help.&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;EDIT: root cause =&amp;gt; null values&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/New-to-QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763330/highlight/true#M394771" target="_self"&gt;Solution 1&lt;/A&gt; or&amp;nbsp;&lt;A href="https://community.qlik.com/t5/New-to-QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763415/highlight/true#M394777" target="_self"&gt;Solution 2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 23:35:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762969#M719553</guid>
      <dc:creator>arnoqlik</dc:creator>
      <dc:date>2024-11-15T23:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762975#M719554</link>
      <description>&lt;P&gt;TableName:&lt;/P&gt;&lt;P&gt;load *,&lt;/P&gt;&lt;P&gt;Revenues - Costs as Profits;&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;Costs,&lt;BR /&gt;Revenues&lt;BR /&gt;&lt;BR /&gt;FROM $(vDATA)\name.qvd (qvd);&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 15:30:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762975#M719554</guid>
      <dc:creator>Chanty4u</dc:creator>
      <dc:date>2020-11-19T15:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762992#M719555</link>
      <description>&lt;P&gt;Profits is still zero&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 16:00:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762992#M719555</guid>
      <dc:creator>arnoqlik</dc:creator>
      <dc:date>2020-11-19T16:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762995#M719556</link>
      <description>&lt;P&gt;if below code is not working .Can you share sample data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;load *,&lt;/P&gt;&lt;P&gt;sum(Revenues) - sum(Costs) as Profits;&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;Costs,&lt;BR /&gt;Revenues&lt;BR /&gt;&lt;BR /&gt;FROM $(vDATA)\name.qvd (qvd);&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 16:08:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1762995#M719556</guid>
      <dc:creator>Chanty4u</dc:creator>
      <dc:date>2020-11-19T16:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763163#M719557</link>
      <description>&lt;P&gt;Here you go&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 07:53:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763163#M719557</guid>
      <dc:creator>arnoqlik</dc:creator>
      <dc:date>2020-11-20T07:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763181#M719558</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/8805"&gt;@arnoqlik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try like below&lt;/P&gt;&lt;P&gt;If(Len(Trim(Revenues))=0, -Costs, Revenues) as Profit&lt;/P&gt;&lt;P&gt;LOAD *, If(Len(Trim(Revenues))=0, -Costs, Revenues) as Profit INLINE [&lt;BR /&gt;Period, UnitProduction, Revenues, Costs&lt;BR /&gt;20201101, 723, 9250,&lt;BR /&gt;20201101, 723, 29982,&lt;BR /&gt;20201101, 723, , 41501525&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Hope always, revenue and cost are in different entries in ur data base.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MayilVahanan_0-1605862910660.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/44513i8E815D19DE3BDE66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MayilVahanan_0-1605862910660.png" alt="MayilVahanan_0-1605862910660.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 09:02:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763181#M719558</guid>
      <dc:creator>MayilVahanan</dc:creator>
      <dc:date>2020-11-20T09:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763265#M719559</link>
      <description>&lt;P&gt;Thanks but I have hundreds of thousands of files in my original file so I can hardly insert a Load * Inline &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Revenues and Costs are in the same .qvd but they are 2 separate fields.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 13:44:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763265#M719559</guid>
      <dc:creator>arnoqlik</dc:creator>
      <dc:date>2020-11-20T13:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763301#M719560</link>
      <description>&lt;P&gt;is it possible that either of the fields are being pulled in as a string?&amp;nbsp; i would load them, create two lists if one is left aligned and the other is right aligned then youll know one is a string.&amp;nbsp; bec this should be a simple&amp;nbsp; Filed1 - Field2 as Filed3&amp;nbsp; exercise so it may not be the expression thats the issue it could be the fields.&amp;nbsp; if one or both of them are strings try this:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/t5/QlikView-Scripting/String-to-number-conversion/td-p/292649" target="_blank"&gt;https://community.qlik.com/t5/QlikView-Scripting/String-to-number-conversion/td-p/292649&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 15:12:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763301#M719560</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2020-11-20T15:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763322#M719561</link>
      <description>&lt;P&gt;You're right. There's probably something wrong with the data format.&lt;/P&gt;&lt;P&gt;Extract of my file:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[ECART]:
LOAD
	CDF,
	Rub,
	Costs_ReelAlloc_Type,
	%DIM_TIME,
	Num#(Costs_Mois_Reel_Montant,'0.00') as Costs,
	Num#(Costs_Mois_Alloc_Montant,'0.00') as Revenues
FROM $(vDATA_DATACOM)\CostsEcartMois.qvd (qvd);

ECART2:
NOCONCATENATE LOAD
	CDF,
	Rub,
	Costs_ReelAlloc_Type,
	%DIM_TIME,
	Costs,
	Revenues,
	Revenues - Costs as Dif
Resident ECART;
Drop Table ECART;
EXIT SCRIPT;&lt;/LI-CODE&gt;&lt;P&gt;This is what I get:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="dif.png" style="width: 505px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/44546iF450AFE4CD8FF827/image-size/large?v=v2&amp;amp;px=999" role="button" title="dif.png" alt="dif.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 15:44:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763322#M719561</guid>
      <dc:creator>arnoqlik</dc:creator>
      <dc:date>2020-11-20T15:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763330#M719562</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/8805"&gt;@arnoqlik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's for sample .. you can replace inline with ur qvd or source..&amp;nbsp;&lt;/P&gt;&lt;P&gt;Logic :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LOAD *, If(Len(Trim(Revenues))=0, -Costs, Revenues) as Profit&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From urqvd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In front end, u can use&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sum(profit)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 16:04:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763330#M719562</guid>
      <dc:creator>MayilVahanan</dc:creator>
      <dc:date>2020-11-20T16:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763415#M719563</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/8805"&gt;@arnoqlik&lt;/a&gt;&amp;nbsp;, try this, maybe is because of the null values :&lt;/P&gt;&lt;P&gt;TableName:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if(isnull(Costs), 0, Costs) as Costs,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if(isnull(Revenues), 0, Revenues) as Revenues,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if(isnull(Revenues), 0, Revenues) - if(isnull(Costs), 0, Costs) as Profits,&lt;BR /&gt;FROM $(vDATA)\name.qvd (qvd);&lt;/P&gt;</description>
      <pubDate>Fri, 20 Nov 2020 22:32:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763415#M719563</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2020-11-20T22:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763476#M719564</link>
      <description>&lt;P&gt;its curious that you would format your number using 0.00 but your number apparently uses comma as decimal point.&amp;nbsp; also try using num instead of num#&lt;/P&gt;&lt;P&gt;can you create a qvw with data with just the script you posted?&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 22:20:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763476#M719564</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2020-11-21T22:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Substract 2 fields in a loading script</title>
      <link>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763614#M719565</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/17935"&gt;@MayilVahanan&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/121051"&gt;@QFabian&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both solutions are working. The problem was indeed the null values!&lt;/P&gt;&lt;P&gt;Thank you again.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 08:31:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SOLVED-Substract-2-fields-in-a-loading-script/m-p/1763614#M719565</guid>
      <dc:creator>arnoqlik</dc:creator>
      <dc:date>2020-11-23T08:31:04Z</dc:date>
    </item>
  </channel>
</rss>

