Using Peek and RangeSum Function in QlikView

Last updated on Oct 25 2021
Harshal Shah

Table of Contents

Using Peek and RangeSum Function in QlikView

The peek() function in QlikView is used to fetch the value of a field from a previous record and use it in calculations.

Input Data

Let us consider the monthly sales figure as shown below. Save the data with file name monthly_sales.csv.

Month,Sales Volume

March,2145

April,2458

May,1245

June,5124

July,7421

August,2584

September,5314

October,7846

November,6532

December,4625

January,8547

February,3265

Load Script

The above data is loaded to QlikView memory by using the script editor. Open the Script editor from the File menu or press Control+E. Choose the Table Files option from for the file containing the above data. Edit the load script to add the following code. Click OK and click Control+R to load the data into QlikView’s memory.

LOAD Month,

     [Sales Volume],

     peek('Sales Volume') as Prevmonth

FROM

[C:\Qlikview\data\monthly_sales.csv]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Creating Sheet Object

Let us create a Table Box sheet object to show the data generated by the above script. Go to the menu item Layout → New Sheet Object → Table Box. The following window appears in which we mention the Title of the table and select the required fields to be displayed. Clicking OK displays the data from the csv file in the QlikView Table Box as shown below. Also set the sort order as shown below to get the result in the same order of the field Month as it is in the source.

image1 30

On completing the above steps and clicking Finish, we get the Table box showing the data as given below.

image2 27

Using peek() Function in Calculations

 

The peek() can be used in calculations involving other columns. Let us display the percentage change for sales volume for each month. The following script achieves this result.

LOAD

 

Month, [Sales Volume],

peek(‘Sales Volume’) as Prevvolume,

(([Sales Volume]-peek(‘Sales Volume’)))/peek(‘Sales Volume’)*100  as Difference

FROM

[C:\Qlikview\data\monthly_sales.csv]

(txt, codepage is 1252, embedded labels, delimiter is ‘,’, msq);

Creating Sheet Object

Let us create a Table Box sheet object to show the data generated by the above script. Go to the menu item Layout → New Sheet Object → Table Box. The following window appears in which we mention the Title of the table and select the required fields to be displayed. Clicking OK displays the data from the CSV file in the QlikView Table Box as shown below.

image3 23

 

 

QlikView – RangeSum Function

The RangeSum() function in QlikView is used to do a selective sum on chosen fields which is not easily achieved by the sum function. It can take expressions containing other functions as its arguments and return the sum of those expressions.

Input Data

Let us consider the monthly sales figure as shown below. Save the data with file name monthly_sales.csv.

Month,Sales Volume

March,2145

April,2458

May,1245

June,5124

July,7421

August,2584

September,5314

October,7846

November,6532

December,4625

January,8547

February,3265

Load Script

The above data is loaded to QlikView memory by using the script editor. Open the Script editor from the File menu or press Control+E. Choose the Table Files option from the Data from Files tab and browse for the file containing the above data. Edit the load script to add the following code. Click OK and click Control+R to load the data into QlikView’s memory.

LOAD

Month, [Sales Volume]

FROM

[C:\Qlikview\data\monthly_sales.csv]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Applying RangeSum() Function

With the above data loaded into QlikView’s memory, we edit the script to add a new column, which will give a rolling sum of the month wise sales volume. For this, we also take the help of the peek function discussed in the earlier chapter to hold the value of the previous record and add it to the sales volume of the current record. The following script achieves the result.

LOAD

Month, [Sales Volume],

rangesum([Sales Volume],peek('Rolling')) as Rolling

FROM

[C:\Qlikview\data\monthly_sales.csv]

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Creating Sheet Object

Let us create a Table Box sheet object to show the data generated by the above given script. Go to the menu Layout → New Sheet Object → Table Box.

The following window appears in which we mention the Title of the table and select the required fields to be displayed. Clicking OK displays the data from the CSV file in the QlikView Table Box as shown below.

image4 22

 

So, this brings us to the end of blog. This Tecklearn ‘Using Peek and RangeSum Function in QlikView’ blog helps you with commonly asked questions if you are looking out for a job in QlikView BI. If you wish to learn QlikView and build a career in Business Intelligence domain, then check out our interactive, QlikView Certification Training, that comes with 24*7 support to guide you throughout your learning period. Please find the link for course details:

https://www.tecklearn.com/course/qlik-view-certification-training/

QlikView Certification Training

About the Course

Tecklearn’s QlikView Certification Training will help you become an expert in Data Visualization with QlikView. Learn all the basics and advanced features of QlikView such as data modelling, reports and dashboards, visualization, object formatting, system table etc. Along with this, you will be given hands-on working experience on real-time projects that will help you pass the QlikView certification exam. You also get hands-on experience in QlikView applications.

Why Should you take QlikView Training?

  • The average annual pay for a QlikView Professional is $122,000. -PayScale.com.
  • Deloitte, Cisco, Qualcomm, Sony, AON & other top Fortune 500 companies use QlikView
  • QlikView – A Leader in 2017 Gartner Magic Quadrant for Business Intelligence & Analytics Platforms (For 7th Consecutive Year).

What you will Learn in this Course?

Introduction to QlikView

  • Concept of Business Intelligence
  • Features and components of QlikView
  • Comparison with other BI tools
  • Architecture
  • Installation & Navigation
  • QVS, QVW and .log files
  • Sheet Objects
  • Dimensions and Expressions
  • Various file types and extensions

Various QlikView Products

  • Overview of the various QlikView products

Introduction to Data and Scripting

  • Structuring the Script
  • Create tabs in the scripts, Debugging of scripts
  • Hands On

Data Model

  • QlikView Data File Types: QVD, QVX
  • System fields
  • Star schema
  • Synthetic Key Tables
  • Data Modelling Considerations
  • Straight and Pivot Table
  • Hands On

Components of Qlik View

  • Sheets and Sheet Objects
  • The List Box
  • The Table Box
  • The Multi Box
  • The Button & Text Object
  • Basic Charts
  • Hands On

Set Analysis

  • Set analysis
  • Working with modifiers, identifiers, operators, example of expressions,
  • Indirect set analysis
  • YTD & MTD

QlikView Functions, Reports and Charts

  • Uses of Expressions
  • Chart Properties: Dimensions
  • Qlikview Functions
  • Adhoc Reports
  • Incremental Load using QVD Files
  • Bookmarks
  • Hands On

Data Analysis

  • What-if Analysis
  • Comparative Analysis
  • Dynamic Reporting or Ad-hoc Reporting
  • Document Analyzer

QlikView Security

  • QlikView security
  • Defining the access controls and levels of access
  • Maintaining the access control database

QlikView Administration

  • QMC (QlikView Management Console)
  • Server Installation & Deployment
  • QlikView Project

Got a question for us? Please mention it in the comments section and we will get back to you.

 

0 responses on "Using Peek and RangeSum Function in QlikView"

Leave a Message

Your email address will not be published. Required fields are marked *