<?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>article How to Create Previous Page Totals with PixelPerfect Visual Basic Scripts in Member Articles</title>
    <link>https://community.qlik.com/t5/Member-Articles/How-to-Create-Previous-Page-Totals-with-PixelPerfect-Visual/ta-p/1476679</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1 class="article-title" style="margin: 0 0 0.5em; font-weight: normal; font-size: 2.5em; font-family: 'Times New Roman'; color: #222222;"&gt;&lt;/H1&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;: This tutorial illustrates how create a PixelPerfect Report with Visual Basic &lt;STRONG&gt;Scripts&lt;/STRONG&gt;. This Report calculates previous page totals using macros. You can use C#, Visual Basic or JavaScript to develop PixelPerfect Scripts. For a C# version of this tutorial refer to "&lt;A href="https://community.qlik.com/docs/DOC-14037"&gt;How to Create Previous Page Totals with PixelPerfect C# Scripts&lt;/A&gt;".&lt;/P&gt;&lt;P style="font-size: 14px; font-family: 'Times New Roman'; color: #333333;"&gt;&lt;/P&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Create a New PixelPerfect Report&lt;/H2&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="107251" alt="Create-a-New-PixelPerfect-Report.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/107251_Create-a-New-PixelPerfect-Report.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select &lt;STRONG&gt;Reports&lt;/STRONG&gt; in the lower left-hand panel&lt;/LI&gt;&lt;LI&gt;Select the &lt;STRONG&gt;PixelPerfect report&lt;/STRONG&gt; type in the panel just above&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;PixelPerfect&lt;/STRONG&gt;&lt;STRONG&gt;Report&lt;/STRONG&gt; in the &lt;STRONG&gt;New&lt;/STRONG&gt; group of the tool bar.&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Name the Report&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107252" alt="Name-the-Report.png" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/107252_Name-the-Report.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Enter "&lt;STRONG&gt;PixelPerfect Previous Page Total with Visual Basic Script" &lt;/STRONG&gt;as name for your report&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;New&lt;/STRONG&gt; in the &lt;STRONG&gt;Template&lt;/STRONG&gt; group of the tool bar.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Create a Table&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107253" alt="Create-a-Table.png" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/107253_Create-a-Table.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Add &lt;STRONG&gt;CH294&lt;/STRONG&gt; as a Level. For more explanation on the Level creation please refer to &lt;A href="https://community.qlik.com/docs/DOC-8405"&gt;How to Create a Simple PixelPerfect Report&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Create the table into the report. Don't insert any column totals.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Add a PageFooter&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107254" alt="Add-a-PageFooter.png" class="image-4 jive-image" src="https://community.qlik.com/legacyfs/online/107254_Add-a-PageFooter.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Right-click on the &lt;STRONG&gt;empty&lt;/STRONG&gt; area in the footer of the page&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;Insert Band&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Choose &lt;STRONG&gt;PageFooter&lt;/STRONG&gt; from the list.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Fill-in the PageFooter&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107255" alt="Fill-in-the-PageFooter.png" class="image-5 jive-image" src="https://community.qlik.com/legacyfs/online/107255_Fill-in-the-PageFooter.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;From the &lt;STRONG&gt;Tool Box&lt;/STRONG&gt; window, select &lt;STRONG&gt;Label &lt;/STRONG&gt;and "drag-and-drop" it&lt;/LI&gt;&lt;LI&gt;Create six new &lt;STRONG&gt;Labels&lt;/STRONG&gt; inside the &lt;STRONG&gt;PageFooter&lt;/STRONG&gt; and rename the first three. Format these &lt;STRONG&gt;Labels&lt;/STRONG&gt; as you prefer.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Set Data Binding&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107256" alt="Set-Data-Binding.png" class="jive-image image-6" src="https://community.qlik.com/legacyfs/online/107256_Set-Data-Binding.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select the &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Click on the &lt;STRONG&gt;smart tag&lt;/STRONG&gt; ("&amp;gt;") button on the upper side of the selected &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Select the&lt;STRONG&gt; Total Sales&lt;/STRONG&gt; field from the drop-down menu in the &lt;STRONG&gt;Data Binding&lt;/STRONG&gt; section.&lt;/LI&gt;&lt;/OL&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;Do these steps for the other two labels.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Set Format String&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107257" alt="Set-Format-String.png" class="jive-image image-7" src="https://community.qlik.com/legacyfs/online/107257_Set-Format-String.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Click on the &lt;STRONG&gt;smart tag&lt;/STRONG&gt; ("&amp;gt;")&lt;/LI&gt;&lt;LI&gt;Click on the &lt;STRONG&gt;browse&lt;/STRONG&gt; button at the far right of the &lt;STRONG&gt;Format String&lt;/STRONG&gt; field to open the &lt;STRONG&gt;FormatString Editor&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;Currency&lt;/STRONG&gt; on the left side of the window&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;$0.00&lt;/STRONG&gt; from the list&lt;/LI&gt;&lt;LI&gt;Click &lt;STRONG&gt;OK&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;Do these steps for the other two labels.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Select the Script Language&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107258" alt="Select-the-Script-Language.png" class="image-8 jive-image" src="https://community.qlik.com/legacyfs/online/107258_Select-the-Script-Language.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Click on&lt;STRONG&gt; Report Explorer&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Select the&lt;STRONG&gt; Visual Basic&lt;/STRONG&gt; field from the drop-down menu in the &lt;STRONG&gt;Scripts&lt;/STRONG&gt; section&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Create the Script&lt;/H2&gt;&lt;P class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;IMG __jive_id="107259" alt="Create-the-Script.png" class="image-9 jive-image" src="https://community.qlik.com/legacyfs/online/107259_Create-the-Script.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Click on &lt;STRONG&gt;Script&lt;/STRONG&gt; on the upper-right side of the window&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: Variable Declaration&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107260" alt="VB-Script--Variable-Declaration.png" class="image-10 jive-image" src="https://community.qlik.com/legacyfs/online/107260_VB-Script--Variable-Declaration.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;CODE style="color: inherit;"&gt;Const allocationStep = 100 Dim currentPageTotal As System.Decimal = 0 Dim runningPagesTotal As System.Decimal = 0 Dim PageNumber As System.Decimal = 0 Dim PageTotal(allocationStep) As System.Decimal&lt;/CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;allocationStep&lt;/STRONG&gt;: Additional allocations for the dynamic array&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;currentPageTotal&lt;/STRONG&gt;: Total Sales on the current page&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;runningPagesTotal&lt;/STRONG&gt;: Total Sales of all pages&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;PageNumber&lt;/STRONG&gt;: Page counter&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;PageTotal&lt;/STRONG&gt;: Array with the total of each single page.&lt;/LI&gt;&lt;/UL&gt;Copy and paste this code inside the &lt;STRONG&gt;Script Editor&lt;/STRONG&gt;.&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryReset Subroutine&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107262" alt="VB-Script--OnSummaryReset-Subroutine.png" class="jive-image image-11" src="https://community.qlik.com/legacyfs/online/107262_VB-Script--OnSummaryReset-Subroutine.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryReset_currentPageTotal(ByVal sender As Object, ByVal e As System.EventArgs) PageNumber += 1 if PageTotal.Length &amp;lt;= PageNumber then ReDim Preserve PageTotal(PageNumber + allocationStep) end if PageTotal(PageNumber) = currentPageTotal currentPageTotal = 0 End Sub &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This sub-routine is executed at the beginning of each new page.&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Code:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Increases the &lt;STRONG&gt;PageNumber&lt;/STRONG&gt; value&lt;/LI&gt;&lt;LI&gt;Check if the array must be &lt;STRONG&gt;resized&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Save the &lt;STRONG&gt;currentPageTotal&lt;/STRONG&gt; value inside the array and reset its value.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-family: inherit; font-style: inherit; font-weight: inherit; font-size: 10pt; line-height: 1.5em;"&gt;Add this code below the previous code.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryRowChanged&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107263" alt="VB-Script--OnSummaryRowChanged.png" class="jive-image image-12" src="https://community.qlik.com/legacyfs/online/107263_VB-Script--OnSummaryRowChanged.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryRowChanged_currentPageTotal(ByVal sender As Object, ByVal e As System.EventArgs)&amp;nbsp;&amp;nbsp; currentPageTotal += DetailReport.GetCurrentColumnValue("Total Sales") End Sub &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code is executed for each row in the page. It retrieves the value of the &lt;STRONG&gt;Total Sales&lt;/STRONG&gt; field and adds it to the previous total. Remember to change the field name if you want to re-use the code for another field.&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryGetResult Current Page&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107264" alt="VB-Script--OnSummaryGetResult-Current-Page.png" class="image-13 jive-image" src="https://community.qlik.com/legacyfs/online/107264_VB-Script--OnSummaryGetResult-Current-Page.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryGetResult_currentPageTotal(ByVal sender As Object, ByVal e As SummaryGetResultEventArgs) e.Result = currentPageTotal e.Handled = True End Sub &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code returns the sum for the current page. It is executed when changing pages. Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryGetResult Previous Page&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107265" alt="VB-Script--OnSummaryGetResult-Previous-Page.png" class="image-14 jive-image" src="https://community.qlik.com/legacyfs/online/107265_VB-Script--OnSummaryGetResult-Previous-Page.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryGetResult_previousPageTotal(ByVal sender As Object, ByVal e As SummaryGetResultEventArgs) e.Result = PageTotal(PageNumber) e.Handled = True End Sub&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code return the total for the previous page. You don't need to insert a -1 in the array index. Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryGetResult Total Sales&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107266" alt="VB-Script--OnSummaryGetResult-Total-Sales.png" class="jive-image image-15" src="https://community.qlik.com/legacyfs/online/107266_VB-Script--OnSummaryGetResult-Total-Sales.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryGetResult_runningPagesTotal(ByVal sender As Object, ByVal e As SummaryGetResultEventArgs) runningPagesTotal += currentPageTotal e.Result = runningPagesTotal e.Handled = True End Sub&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code increase the value of &lt;STRONG&gt;runningPagesTotal by&lt;/STRONG&gt; the &lt;STRONG&gt;currentPageTotal&lt;/STRONG&gt; and returns the value of the Total Sales of each preceding page. Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Associate the Sub-routines to the Events to Calculate Current Page Total&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107267" alt="Associate-the-Sub-routines-to-the-Events-to-Calcul.png" class="jive-image image-16" src="https://community.qlik.com/legacyfs/online/107267_Associate-the-Sub-routines-to-the-Events-to-Calcul.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Now we associate sub-routines to the events specified on the left column.&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select the first &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;On&lt;STRONG&gt; Property Grid&lt;/STRONG&gt; expand, the &lt;STRONG&gt;Scripts&lt;/STRONG&gt; section&lt;/LI&gt;&lt;LI&gt;Insert:&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryGetResult_currentPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Get Result &lt;/STRONG&gt;field.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryReset_currentPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Reset &lt;/STRONG&gt;field&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryRowChanged_currentPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Row Change &lt;/STRONG&gt;field.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Associate the Sub-routines to the Events to Calculate Preceding Page Total&lt;/H2&gt;&lt;P class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;IMG __jive_id="107268" alt="Associate-the-Sub-routines-to-the-Events-to-Calcul-1.png" class="image-17 jive-image" src="https://community.qlik.com/legacyfs/online/107268_Associate-the-Sub-routines-to-the-Events-to-Calcul-1.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select the second &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;On &lt;STRONG&gt;Property Grid,&lt;/STRONG&gt; expand the &lt;STRONG&gt;Scripts&lt;/STRONG&gt; section&lt;/LI&gt;&lt;LI&gt;Insert:&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryGetResult_previousPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Get Result &lt;/STRONG&gt;field.&lt;/LI&gt;&lt;/UL&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Do these steps also for the last Label. Insert &lt;STRONG&gt;OnSummaryGetResult_runningPagesTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Get Result &lt;/STRONG&gt;field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Generate Preview&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107269" alt="Generate-Preview.png" class="image-18 jive-image" src="https://community.qlik.com/legacyfs/online/107269_Generate-Preview.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Select &lt;STRONG&gt;Preview&lt;/STRONG&gt; in the &lt;STRONG&gt;Actions&lt;/STRONG&gt; group in the &lt;STRONG&gt;Reports&lt;/STRONG&gt; window&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;The Result&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107270" alt="The-Result.png" class="jive-image image-19" src="https://community.qlik.com/legacyfs/online/107270_The-Result.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2015 22:18:57 GMT</pubDate>
    <dc:creator>Frank_S</dc:creator>
    <dc:date>2015-11-25T22:18:57Z</dc:date>
    <item>
      <title>How to Create Previous Page Totals with PixelPerfect Visual Basic Scripts</title>
      <link>https://community.qlik.com/t5/Member-Articles/How-to-Create-Previous-Page-Totals-with-PixelPerfect-Visual/ta-p/1476679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;H1 class="article-title" style="margin: 0 0 0.5em; font-weight: normal; font-size: 2.5em; font-family: 'Times New Roman'; color: #222222;"&gt;&lt;/H1&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;: This tutorial illustrates how create a PixelPerfect Report with Visual Basic &lt;STRONG&gt;Scripts&lt;/STRONG&gt;. This Report calculates previous page totals using macros. You can use C#, Visual Basic or JavaScript to develop PixelPerfect Scripts. For a C# version of this tutorial refer to "&lt;A href="https://community.qlik.com/docs/DOC-14037"&gt;How to Create Previous Page Totals with PixelPerfect C# Scripts&lt;/A&gt;".&lt;/P&gt;&lt;P style="font-size: 14px; font-family: 'Times New Roman'; color: #333333;"&gt;&lt;/P&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Create a New PixelPerfect Report&lt;/H2&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="107251" alt="Create-a-New-PixelPerfect-Report.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/107251_Create-a-New-PixelPerfect-Report.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select &lt;STRONG&gt;Reports&lt;/STRONG&gt; in the lower left-hand panel&lt;/LI&gt;&lt;LI&gt;Select the &lt;STRONG&gt;PixelPerfect report&lt;/STRONG&gt; type in the panel just above&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;PixelPerfect&lt;/STRONG&gt;&lt;STRONG&gt;Report&lt;/STRONG&gt; in the &lt;STRONG&gt;New&lt;/STRONG&gt; group of the tool bar.&lt;/LI&gt;&lt;/OL&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Name the Report&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107252" alt="Name-the-Report.png" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/107252_Name-the-Report.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Enter "&lt;STRONG&gt;PixelPerfect Previous Page Total with Visual Basic Script" &lt;/STRONG&gt;as name for your report&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;New&lt;/STRONG&gt; in the &lt;STRONG&gt;Template&lt;/STRONG&gt; group of the tool bar.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Create a Table&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107253" alt="Create-a-Table.png" class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/107253_Create-a-Table.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Add &lt;STRONG&gt;CH294&lt;/STRONG&gt; as a Level. For more explanation on the Level creation please refer to &lt;A href="https://community.qlik.com/docs/DOC-8405"&gt;How to Create a Simple PixelPerfect Report&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Create the table into the report. Don't insert any column totals.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Add a PageFooter&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107254" alt="Add-a-PageFooter.png" class="image-4 jive-image" src="https://community.qlik.com/legacyfs/online/107254_Add-a-PageFooter.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Right-click on the &lt;STRONG&gt;empty&lt;/STRONG&gt; area in the footer of the page&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;Insert Band&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Choose &lt;STRONG&gt;PageFooter&lt;/STRONG&gt; from the list.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Fill-in the PageFooter&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107255" alt="Fill-in-the-PageFooter.png" class="image-5 jive-image" src="https://community.qlik.com/legacyfs/online/107255_Fill-in-the-PageFooter.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;From the &lt;STRONG&gt;Tool Box&lt;/STRONG&gt; window, select &lt;STRONG&gt;Label &lt;/STRONG&gt;and "drag-and-drop" it&lt;/LI&gt;&lt;LI&gt;Create six new &lt;STRONG&gt;Labels&lt;/STRONG&gt; inside the &lt;STRONG&gt;PageFooter&lt;/STRONG&gt; and rename the first three. Format these &lt;STRONG&gt;Labels&lt;/STRONG&gt; as you prefer.&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Set Data Binding&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107256" alt="Set-Data-Binding.png" class="jive-image image-6" src="https://community.qlik.com/legacyfs/online/107256_Set-Data-Binding.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select the &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Click on the &lt;STRONG&gt;smart tag&lt;/STRONG&gt; ("&amp;gt;") button on the upper side of the selected &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Select the&lt;STRONG&gt; Total Sales&lt;/STRONG&gt; field from the drop-down menu in the &lt;STRONG&gt;Data Binding&lt;/STRONG&gt; section.&lt;/LI&gt;&lt;/OL&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;Do these steps for the other two labels.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Set Format String&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107257" alt="Set-Format-String.png" class="jive-image image-7" src="https://community.qlik.com/legacyfs/online/107257_Set-Format-String.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Click on the &lt;STRONG&gt;smart tag&lt;/STRONG&gt; ("&amp;gt;")&lt;/LI&gt;&lt;LI&gt;Click on the &lt;STRONG&gt;browse&lt;/STRONG&gt; button at the far right of the &lt;STRONG&gt;Format String&lt;/STRONG&gt; field to open the &lt;STRONG&gt;FormatString Editor&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;Currency&lt;/STRONG&gt; on the left side of the window&lt;/LI&gt;&lt;LI&gt;Select &lt;STRONG&gt;$0.00&lt;/STRONG&gt; from the list&lt;/LI&gt;&lt;LI&gt;Click &lt;STRONG&gt;OK&lt;/STRONG&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;Do these steps for the other two labels.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-style: inherit; font-family: inherit; margin: 0 0 1.5em; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Select the Script Language&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107258" alt="Select-the-Script-Language.png" class="image-8 jive-image" src="https://community.qlik.com/legacyfs/online/107258_Select-the-Script-Language.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Click on&lt;STRONG&gt; Report Explorer&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Select the&lt;STRONG&gt; Visual Basic&lt;/STRONG&gt; field from the drop-down menu in the &lt;STRONG&gt;Scripts&lt;/STRONG&gt; section&lt;/LI&gt;&lt;/OL&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Create the Script&lt;/H2&gt;&lt;P class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;IMG __jive_id="107259" alt="Create-the-Script.png" class="image-9 jive-image" src="https://community.qlik.com/legacyfs/online/107259_Create-the-Script.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Click on &lt;STRONG&gt;Script&lt;/STRONG&gt; on the upper-right side of the window&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: Variable Declaration&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107260" alt="VB-Script--Variable-Declaration.png" class="image-10 jive-image" src="https://community.qlik.com/legacyfs/online/107260_VB-Script--Variable-Declaration.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;CODE style="color: inherit;"&gt;Const allocationStep = 100 Dim currentPageTotal As System.Decimal = 0 Dim runningPagesTotal As System.Decimal = 0 Dim PageNumber As System.Decimal = 0 Dim PageTotal(allocationStep) As System.Decimal&lt;/CODE&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;allocationStep&lt;/STRONG&gt;: Additional allocations for the dynamic array&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;currentPageTotal&lt;/STRONG&gt;: Total Sales on the current page&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;runningPagesTotal&lt;/STRONG&gt;: Total Sales of all pages&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;PageNumber&lt;/STRONG&gt;: Page counter&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;PageTotal&lt;/STRONG&gt;: Array with the total of each single page.&lt;/LI&gt;&lt;/UL&gt;Copy and paste this code inside the &lt;STRONG&gt;Script Editor&lt;/STRONG&gt;.&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryReset Subroutine&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107262" alt="VB-Script--OnSummaryReset-Subroutine.png" class="jive-image image-11" src="https://community.qlik.com/legacyfs/online/107262_VB-Script--OnSummaryReset-Subroutine.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryReset_currentPageTotal(ByVal sender As Object, ByVal e As System.EventArgs) PageNumber += 1 if PageTotal.Length &amp;lt;= PageNumber then ReDim Preserve PageTotal(PageNumber + allocationStep) end if PageTotal(PageNumber) = currentPageTotal currentPageTotal = 0 End Sub &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This sub-routine is executed at the beginning of each new page.&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Code:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Increases the &lt;STRONG&gt;PageNumber&lt;/STRONG&gt; value&lt;/LI&gt;&lt;LI&gt;Check if the array must be &lt;STRONG&gt;resized&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Save the &lt;STRONG&gt;currentPageTotal&lt;/STRONG&gt; value inside the array and reset its value.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;SPAN style="font-family: inherit; font-style: inherit; font-weight: inherit; font-size: 10pt; line-height: 1.5em;"&gt;Add this code below the previous code.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryRowChanged&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107263" alt="VB-Script--OnSummaryRowChanged.png" class="jive-image image-12" src="https://community.qlik.com/legacyfs/online/107263_VB-Script--OnSummaryRowChanged.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryRowChanged_currentPageTotal(ByVal sender As Object, ByVal e As System.EventArgs)&amp;nbsp;&amp;nbsp; currentPageTotal += DetailReport.GetCurrentColumnValue("Total Sales") End Sub &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code is executed for each row in the page. It retrieves the value of the &lt;STRONG&gt;Total Sales&lt;/STRONG&gt; field and adds it to the previous total. Remember to change the field name if you want to re-use the code for another field.&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryGetResult Current Page&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107264" alt="VB-Script--OnSummaryGetResult-Current-Page.png" class="image-13 jive-image" src="https://community.qlik.com/legacyfs/online/107264_VB-Script--OnSummaryGetResult-Current-Page.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryGetResult_currentPageTotal(ByVal sender As Object, ByVal e As SummaryGetResultEventArgs) e.Result = currentPageTotal e.Handled = True End Sub &lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code returns the sum for the current page. It is executed when changing pages. Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryGetResult Previous Page&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107265" alt="VB-Script--OnSummaryGetResult-Previous-Page.png" class="image-14 jive-image" src="https://community.qlik.com/legacyfs/online/107265_VB-Script--OnSummaryGetResult-Previous-Page.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryGetResult_previousPageTotal(ByVal sender As Object, ByVal e As SummaryGetResultEventArgs) e.Result = PageTotal(PageNumber) e.Handled = True End Sub&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code return the total for the previous page. You don't need to insert a -1 in the array index. Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;VB Script: OnSummaryGetResult Total Sales&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107266" alt="VB-Script--OnSummaryGetResult-Total-Sales.png" class="jive-image image-15" src="https://community.qlik.com/legacyfs/online/107266_VB-Script--OnSummaryGetResult-Total-Sales.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="padding: 9.5px; margin: 0 0 10px; font-size: 13px; border-left-width: 1px; background-color: #f5f5f5;"&gt;&lt;CODE style="color: inherit;"&gt;Private Sub OnSummaryGetResult_runningPagesTotal(ByVal sender As Object, ByVal e As SummaryGetResultEventArgs) runningPagesTotal += currentPageTotal e.Result = runningPagesTotal e.Handled = True End Sub&lt;/CODE&gt;&lt;/PRE&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;This code increase the value of &lt;STRONG&gt;runningPagesTotal by&lt;/STRONG&gt; the &lt;STRONG&gt;currentPageTotal&lt;/STRONG&gt; and returns the value of the Total Sales of each preceding page. Add this code below the previous code.&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Associate the Sub-routines to the Events to Calculate Current Page Total&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107267" alt="Associate-the-Sub-routines-to-the-Events-to-Calcul.png" class="jive-image image-16" src="https://community.qlik.com/legacyfs/online/107267_Associate-the-Sub-routines-to-the-Events-to-Calcul.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Now we associate sub-routines to the events specified on the left column.&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select the first &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;On&lt;STRONG&gt; Property Grid&lt;/STRONG&gt; expand, the &lt;STRONG&gt;Scripts&lt;/STRONG&gt; section&lt;/LI&gt;&lt;LI&gt;Insert:&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryGetResult_currentPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Get Result &lt;/STRONG&gt;field.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryReset_currentPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Reset &lt;/STRONG&gt;field&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryRowChanged_currentPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Row Change &lt;/STRONG&gt;field.&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Associate the Sub-routines to the Events to Calculate Preceding Page Total&lt;/H2&gt;&lt;P class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;IMG __jive_id="107268" alt="Associate-the-Sub-routines-to-the-Events-to-Calcul-1.png" class="image-17 jive-image" src="https://community.qlik.com/legacyfs/online/107268_Associate-the-Sub-routines-to-the-Events-to-Calcul-1.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;OL style="margin: 0 1.5em 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;LI&gt;Select the second &lt;STRONG&gt;Label&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;On &lt;STRONG&gt;Property Grid,&lt;/STRONG&gt; expand the &lt;STRONG&gt;Scripts&lt;/STRONG&gt; section&lt;/LI&gt;&lt;LI&gt;Insert:&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;OnSummaryGetResult_previousPageTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Get Result &lt;/STRONG&gt;field.&lt;/LI&gt;&lt;/UL&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Do these steps also for the last Label. Insert &lt;STRONG&gt;OnSummaryGetResult_runningPagesTotal &lt;/STRONG&gt;on &lt;STRONG&gt;Summary Get Result &lt;/STRONG&gt;field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;Generate Preview&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107269" alt="Generate-Preview.png" class="image-18 jive-image" src="https://community.qlik.com/legacyfs/online/107269_Generate-Preview.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;DIV class="step-image-container" style="margin: 0 0 1em; padding: 5px; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0 0 1.5em; font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;Select &lt;STRONG&gt;Preview&lt;/STRONG&gt; in the &lt;STRONG&gt;Actions&lt;/STRONG&gt; group in the &lt;STRONG&gt;Reports&lt;/STRONG&gt; window&lt;/P&gt;&lt;/DIV&gt;&lt;P class="step-container" style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;&lt;/P&gt;&lt;H2 class="step-title" style="margin: 0 0 0.75em; border-bottom-style: solid; border-bottom-color: #cccccc; font-weight: normal; font-style: inherit; font-size: 1.5em; font-family: inherit; color: #222222;"&gt;The Result&lt;/H2&gt;&lt;P&gt;&lt;IMG __jive_id="107270" alt="The-Result.png" class="jive-image image-19" src="https://community.qlik.com/legacyfs/online/107270_The-Result.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2015 22:18:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/How-to-Create-Previous-Page-Totals-with-PixelPerfect-Visual/ta-p/1476679</guid>
      <dc:creator>Frank_S</dc:creator>
      <dc:date>2015-11-25T22:18:57Z</dc:date>
    </item>
  </channel>
</rss>

