<?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: Using a variable properly inside an IF statement that sums in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266305#M398873</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The variable I am using is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vConsum&amp;nbsp; = ($(vTrans) * $(vAtin))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vTrans = (sum(tcount/3600))&lt;/P&gt;&lt;P&gt;vAtin = (sum(expend)/sum(tcount))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'tcount' and 'expend' are fields being pulled in from the script editor. I had put the () around the variables thinking that would help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Jan 2017 21:38:17 GMT</pubDate>
    <dc:creator>mp802377</dc:creator>
    <dc:date>2017-01-03T21:38:17Z</dc:date>
    <item>
      <title>Using a variable properly inside an IF statement that sums</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266303#M398871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I run the data every hour grabbing from multiple data sets and it is of course populating my charts&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data source I am grabbing from tables are populated at different times, based on system performance. If the system is running slow, the data populates slow so on that hour I run it, it may not all be there. If it is running fine, the data is all there. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because of this the data mwill not have a null value, but a small value and the chart line goes straight down. For this reason, I don't want to plot those missing or low values. I had to create my expression for today() only. I want to see any null values that are not today because if they are null and it is not today that means there is a problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my formula and works:&lt;/P&gt;&lt;P&gt;=if(Date(today()),Sum({$&amp;lt;-={"&amp;lt;$(=1000)"}&amp;gt;}transactions),sum(transactions))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this works, but for variables, it does not work. I have a lot of charts, most summing a variable. How would I replace transactions with a variable like vConsum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried below and it came back as an error&lt;/P&gt;&lt;P&gt;=if(Date(today()),Sum({$&amp;lt;-={"&amp;lt;$(=1000)"}&amp;gt;}vConsum),sum(vConsum))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I get that to work with a variable that was created? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2017 21:21:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266303#M398871</guid>
      <dc:creator>mp802377</dc:creator>
      <dc:date>2017-01-03T21:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable properly inside an IF statement that sums</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266304#M398872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;=if(Date(today()),Sum({$&amp;lt;-={"&amp;lt;$(=1000)"}&amp;gt;} &lt;SPAN style="color: #ff0000;"&gt;$(vConsum)&lt;/SPAN&gt;),sum(&lt;SPAN style="color: #ff0000;"&gt;$(vConsum)&lt;/SPAN&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF not&lt;/P&gt;&lt;P&gt;Can you post your vConsum variable expression what you are using?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2017 21:31:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266304#M398872</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-01-03T21:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable properly inside an IF statement that sums</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266305#M398873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The variable I am using is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vConsum&amp;nbsp; = ($(vTrans) * $(vAtin))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vTrans = (sum(tcount/3600))&lt;/P&gt;&lt;P&gt;vAtin = (sum(expend)/sum(tcount))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'tcount' and 'expend' are fields being pulled in from the script editor. I had put the () around the variables thinking that would help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2017 21:38:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266305#M398873</guid>
      <dc:creator>mp802377</dc:creator>
      <dc:date>2017-01-03T21:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable properly inside an IF statement that sums</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266306#M398874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vTrans = '=Sum(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;tcount&lt;/SPAN&gt;)/3600';&lt;/P&gt;&lt;P&gt;LET vAtin = '=Sum(expend)/Sum(tcount)';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vConsum = '=(vTrans)/(vAtin)';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2017 22:16:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266306#M398874</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-01-03T22:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable properly inside an IF statement that sums</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266307#M398875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had created those variables above under settings&amp;nbsp; -- &amp;gt; variable overview. So are you saying that my variables I should create in the script editor instead?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did that. It is the same outcome, does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But for best practice, do I create all variables in Script Editor?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2017 22:49:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266307#M398875</guid>
      <dc:creator>mp802377</dc:creator>
      <dc:date>2017-01-03T22:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable properly inside an IF statement that sums</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266308#M398876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, try creating your variables in script editor and see. Should not make any difference. However, would it be possible to share a sample app with scrambled data?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2017 22:50:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266308#M398876</guid>
      <dc:creator>vishsaggi</dc:creator>
      <dc:date>2017-01-03T22:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable properly inside an IF statement that sums</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266309#M398877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I logged off and after a nights rest, I in the morning I saw my problem. I want to thank you for your help, but I figured it out (YES), so if anyone is having same issue, the expression below worked for me. I was sitting here thinking, isn't the point of $( to sum a variable, so why did I need a sum in front of it. And that was it. I was confusing Qlikview.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if($(vConsum)&amp;gt;1000 and Date(today()), $(vConsum), Null())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your help and time. I am trying to learn best practices for Qlikview, the book I read was just a developers book and didn't dive into best practices. It had us create the variables in the Variable Overview. I also want to say how much I appreciate the forum, there is everything in here and I really try to search before I ask a&amp;nbsp; question.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2017 15:22:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-variable-properly-inside-an-IF-statement-that-sums/m-p/1266309#M398877</guid>
      <dc:creator>mp802377</dc:creator>
      <dc:date>2017-01-04T15:22:14Z</dc:date>
    </item>
  </channel>
</rss>

