<?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 Rounding ... From Fraction to Whole Number in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Rounding-From-Fraction-to-Whole-Number/m-p/735655#M674844</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are a relatively new QlikView developer, you may find it difficult to accurately round fractions to whole numbers.&amp;nbsp; QlikView’s Round function is a great function to utilize until you run into calculation issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way to ensure you are accurately rounding to the whole number involves creating a function/variable via an Include file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Step 1: &lt;/STRONG&gt; Create a reusable and universal formatting variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For simplicity, I created a text file and named it as “Formatters”.&amp;nbsp; Inside the text file I created numerous variables/functions that will be loaded into all of my QlikView application to ensure the formatting is consistent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the code used in the include file for Rounding to Whole Numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9pt; font-family: 'Courier New';"&gt;v_WholeNumber&lt;/EM&gt;&lt;/STRONG&gt; = [NUM(NUM(Floor($1) + IF(NUM(Round(Frac($1),.01)) &amp;gt;= .50,1,0)))];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal of &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9pt; font-family: 'Courier New';"&gt;v_WholeNumber&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp; is to separate and evaluate the fractional part of the number.&amp;nbsp; If the fraction, when rounded to 2 decimal places, is equal to or exceeds .50, 1 is added to integer of the field being evaluated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$1 represents the field that you will evaluate in the script.&amp;nbsp; The exact code for your script is contained in &lt;STRONG&gt;Step 4&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Step 2: &lt;/STRONG&gt; Create the Load Statement for the “Formatters” text file in your QlikView Application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the Load statement is complete, it will look similar to the following.&lt;/P&gt;&lt;P&gt;$(Include=\...\...\...\includefiles\formatters.txt);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Step 3: &lt;/STRONG&gt;&lt;/SPAN&gt; Reload your QlikView application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Step 4: &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&amp;nbsp; &lt;/STRONG&gt;Integrate and utilize the newly created variable/function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example Situation and Code:&lt;/P&gt;&lt;P&gt;The application you are creating is comparing a company’s sales performance against the company’s budget. Due to the budget creating process, the &lt;SPAN style="color: #800000; font-family: 'Courier New'; font-size: 12px;"&gt;Budget Quantity&lt;/SPAN&gt; can be fractional while sales occur in complete or whole units (integers).&lt;/P&gt;&lt;P&gt;To convert the company’s &lt;SPAN style="color: #800000; font-family: 'Courier New'; font-size: 12px;"&gt;Budget Quantity&lt;/SPAN&gt; to an integer utilize the &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9pt; font-family: 'Courier New';"&gt;v_WholeNumber&lt;/EM&gt;&lt;/STRONG&gt; Function which is now loaded into your application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code in Load Script:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9.0pt; font-family: 'Courier New';"&gt;$(v_WholeNumber([Budget Quantity]))&lt;/EM&gt;&lt;/STRONG&gt; &lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: blue;"&gt;as&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: maroon;"&gt;[Budget Quantity]&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;,&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Jul 2014 19:48:17 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-07-23T19:48:17Z</dc:date>
    <item>
      <title>Rounding ... From Fraction to Whole Number</title>
      <link>https://community.qlik.com/t5/QlikView/Rounding-From-Fraction-to-Whole-Number/m-p/735655#M674844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are a relatively new QlikView developer, you may find it difficult to accurately round fractions to whole numbers.&amp;nbsp; QlikView’s Round function is a great function to utilize until you run into calculation issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One way to ensure you are accurately rounding to the whole number involves creating a function/variable via an Include file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Step 1: &lt;/STRONG&gt; Create a reusable and universal formatting variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For simplicity, I created a text file and named it as “Formatters”.&amp;nbsp; Inside the text file I created numerous variables/functions that will be loaded into all of my QlikView application to ensure the formatting is consistent.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the code used in the include file for Rounding to Whole Numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9pt; font-family: 'Courier New';"&gt;v_WholeNumber&lt;/EM&gt;&lt;/STRONG&gt; = [NUM(NUM(Floor($1) + IF(NUM(Round(Frac($1),.01)) &amp;gt;= .50,1,0)))];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The goal of &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9pt; font-family: 'Courier New';"&gt;v_WholeNumber&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp; is to separate and evaluate the fractional part of the number.&amp;nbsp; If the fraction, when rounded to 2 decimal places, is equal to or exceeds .50, 1 is added to integer of the field being evaluated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$1 represents the field that you will evaluate in the script.&amp;nbsp; The exact code for your script is contained in &lt;STRONG&gt;Step 4&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline;"&gt;Step 2: &lt;/STRONG&gt; Create the Load Statement for the “Formatters” text file in your QlikView Application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the Load statement is complete, it will look similar to the following.&lt;/P&gt;&lt;P&gt;$(Include=\...\...\...\includefiles\formatters.txt);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Step 3: &lt;/STRONG&gt;&lt;/SPAN&gt; Reload your QlikView application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Step 4: &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&amp;nbsp; &lt;/STRONG&gt;Integrate and utilize the newly created variable/function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example Situation and Code:&lt;/P&gt;&lt;P&gt;The application you are creating is comparing a company’s sales performance against the company’s budget. Due to the budget creating process, the &lt;SPAN style="color: #800000; font-family: 'Courier New'; font-size: 12px;"&gt;Budget Quantity&lt;/SPAN&gt; can be fractional while sales occur in complete or whole units (integers).&lt;/P&gt;&lt;P&gt;To convert the company’s &lt;SPAN style="color: #800000; font-family: 'Courier New'; font-size: 12px;"&gt;Budget Quantity&lt;/SPAN&gt; to an integer utilize the &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9pt; font-family: 'Courier New';"&gt;v_WholeNumber&lt;/EM&gt;&lt;/STRONG&gt; Function which is now loaded into your application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code in Load Script:&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;&lt;EM style="color: gray; font-size: 9.0pt; font-family: 'Courier New';"&gt;$(v_WholeNumber([Budget Quantity]))&lt;/EM&gt;&lt;/STRONG&gt; &lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: blue;"&gt;as&lt;/SPAN&gt; &lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: maroon;"&gt;[Budget Quantity]&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.0pt; font-family: 'Courier New'; color: black;"&gt;,&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 19:48:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Rounding-From-Fraction-to-Whole-Number/m-p/735655#M674844</guid>
      <dc:creator />
      <dc:date>2014-07-23T19:48:17Z</dc:date>
    </item>
  </channel>
</rss>

