DS Technical Brief Storing and Reusing QlikView Expressions With QlikView Expressor En

Share Embed Donate


Short Description

Qlikview...

Description

STORING AND REUSING QLIKVIEW EXPRESSIONS WITH QLIKVIEW EXPRESSOR A QlikView Expressor Technical Brief

May 2013

qlikview.com

Table of Contents About This Document

3

Introduction – “Good Data”

3

QlikView Expressions

4

QlikView Expressor

5

The Business-Logic Design Technique

6

Modularize your QlikView Expressions in QlikView Expressor

6

Create the QlikView Expressor Dataflow

8

Create the Deployment Package

10

Create the QlikView Application

10

Modify the centralized rule/expression

13

Summary

15

Storing and Reusing QlikView Expressions with QlikView Expressor | 2

About This Document This document introduces a business-logic design technique that allows for the creation, maintenance and storage of QlikView specific expressions from within a QlikView Expressor Dataflow (QlikView specific expressions include any formula or code written with the QlikView scripting syntax.) These expressions can then be stored in and referenced by QlikView variables within a QlikView application. A QlikView Expressor project, sample data and QlikView application have been packaged and made available on the QlikCommunity. Refer to the included Readme.txt file for setup instructions. It is recommended to review the actual sample for additional context as this document is not intended to be a complete step-by-step tutorial. In order to understand this design technique, a working knowledge of QlikView Expressor Dataflows, the QlikView Expressor Connector and QlikView is needed.

Introduction – “Good Data” Cultivating values that emphasize consistency and reusability is crucial when introducing successful data governance practices. Common problems with many decision support systems are the amount of variation, redundancy and overlap that exists within the data models and business-logic used across multiple analytical applications. These problems can delay critical decisions and disrupt IT operations while users struggle to verify the truth in data. Having data is one thing, having “good data” is another. With the volume of data increasing - it is important to create a structured and consolidated data management layer that contains reusable and consistent definitions. This in turn gives developers and business users assurance that the data they are using, whether to develop applications or make decisions, is “good data”. Having good data also expedites the process of creating new applications and eliminates much of the guesswork in maintaining applications as business requirements evolve over time.

Storing and Reusing QlikView Expressions with QlikView Expressor | 3

QlikView Expressions QlikView expressions consist of script functions, fields, operators, labels and variables which are combined with script syntax used in QlikView applications. Expressions are commonly used in the script editor when defining and loading data, as well as in various sheet objects to define calculated measures and dimensions.

Figure 1: Expressions Defined in a Load Script

Figure 2: Expressions Defined in a Sheet Object

Storing and Reusing QlikView Expressions with QlikView Expressor | 4

Though this capability is pragmatic and offers flexibility, without a uniformed method to define such logic, QlikView applications could report inconsistent results due to the possible variations of expressions used in the application design. In order to apply data governance practices to a QlikView deployment, reducing redundancy and increasing inconsistency amongst the applications are necessary.

QlikView Expressor Using QlikView Expressor (QVE) to manage and prepare data for QlikView is a great step towards adding data governance and data management to your QlikView deployment. Not only can you visualize where data originates and its final destination, but you can also create reusable parameterized business-logic that can be shared across multiple applications. With added functionality to support version control, data conformance, data lineage and impact analysis, you are well on your way to introducing a powerful data governance framework. (For more information on QlikView Expressor, please see the QlikView Expressor product page.) By design, QlikView Expressor uses a Transform Operator to maintain Expression and Function Rules that manipulate existing and/or add new data. When transforming data, typically a QVE expression is used. The result is a transformed data column defined in the output of the final QlikView table model.

Figure 3: Default QlikView Expressor Dataflow, Transform Operator and Rules Editor with Expression

Storing and Reusing QlikView Expressions with QlikView Expressor | 5

But, what if you could centrally store an actual QlikView scripted expression as part of the data management process, instead of the subsequent column value? It would allow a single version of that expression to be used with in all QlikView applications and sheet objects; reducing maintenance significantly if changes are to be made. As a result, this increases productivity, accuracy and data confidence since there is only one place to make modifications within QlikView Expressor.

The Business-Logic Design Technique MODULARIZE YOUR QLIKVIEW EXPRESSIONS IN QLIKVIEW EXPRESSOR To start this process, create a new QlikView Expressor Datascript Module to provide greater portability and simplicity. Datascript Modules extend the current functionality of the product by using Datascript, the QlikView Expressor scripting language. In this example, the Datascript Module contains the appropriate syntax to store the QlikView specific expressions. In QlikView Expressor Desktop, open RulesDSM to see the code.

Figure 4: QlikView Expressor Workspace With Artifacts

Storing and Reusing QlikView Expressions with QlikView Expressor | 6

Figure 5: QlikView Expressor Datascript Module with Datascript Syntax That Defines QlikView Expressions

Note the local variable of the data type table {} is named CommonMeasures – this structure of code is the only one that needs to be modified to include your own QlikView expression syntax as needed. In this example, there are a few simple aggregate expressions using the QlikView SUM() function. Each expression is defined with: • A QlikView variable name: vMSR_SumOfSales - used as the variable name within the QlikView application to be referenced as =$(vMSR_SumOfSales) • The actual QlikView expression: Sum (LINEPRICE) – the expression to be stored in the variable • Additional context that can be used for labels, titles, comments, etc.: Sum of Sales The rest of the code does not need to be modified. It contains a standard function used to iterate over the table. That function is used in the next step.

Storing and Reusing QlikView Expressions with QlikView Expressor | 7

CREATE THE QLIKVIEW EXPRESSOR DATAFLOW Next, create a multi-step Dataflow where the first step (ReadRules) will read the centrally defined expressions and write them to a QlikView data file / stream for use in the QlikView application. The second step (ReadSalesData) will access some organizational sales data, used to create sheet objects that will help drive decisions, and write it to a QlikView data file/stream.

Figure 7: QlikView Expressor Multi-step Dataflow with Read Custom Operator Using the Read Custom Operator allows the QVE Datascript to create custom operations that access data. In the read() function, make a call to the BuildCommonMeasuresIterator() function (defined in the previously discussed Datascript Module) return the following string columns: • MeasureName • MeasureExpression • MeasurePurposeThese

Figure 8: Inside the Read Custom Operator Calling the Function BuildCommonMeasuresIterator

Storing and Reusing QlikView Expressions with QlikView Expressor | 8

Next, simply write out the data to QlikView using the QlikView Write Operator.

Figure 9: Write QlikView Operator Using New Schema Defined from Upstream Output

Figure 10: Second Step that Simply Reads the Data Source and Prepares it for QlikView Next, add a second step (ReadSalesData) to the Dataflow to simply access and write data to a new QlikView data file.

Storing and Reusing QlikView Expressions with QlikView Expressor | 9

CREATE THE DEPLOYMENT PACKAGE In order to share the dataflow(s) and the QlikView data to a QlikView application (QVW) using the QlikView Expressor Connector, create a QVE Deployment Package. This Deployment Package (RulesPacakge) is defined with the one Dataflow we need, ExpressionsDF.

Figure 11: QlikView Expressor Deployment Package with One Dataflow CREATE THE QLIKVIEW APPLICATION Use QlikView Desktop within the QlikView application script editor, then use the QlikView Expressor Connector to access the Deployment Package to pull the two data outputs (models) needed. Please note that by default, the paths used in the CUSTOM CONNECT statement are populated with the location of your QlikView Expressor Workspace and package defined by your files system when you navigate the interface. NOTE: The included sample contains hardcoded variables for simplicity. After the LOAD statement, create a table reference named WriteCommonRules. Then create a small for-loop to load the values from the resulting rules table into dynamically named QlikView variables. for i=0 to NoOfRows(‘WriteCommonRules’)-1 LET tempVarName = Peek(‘MeasureName’,$(i), ‘WriteCommonRules’); LET $(tempVarName) = Peek(‘MeasureExpression’,$(i), ‘WriteCommonRules’); LET $(tempVarName)_Label = Peek(‘MeasurePurpose’,$(i), ‘WriteCommonRules’); NEXT

Storing and Reusing QlikView Expressions with QlikView Expressor | 10

Figure 12: QlikView Script Editor with Code In the QlikView script editor, I also create a new tab for the SalesOrderData table. It is a simple load and SQL statement that gets data from the second step of the Dataflow. Notice that the columns used in the load script are the same ones that have been defined in our expressions. • LINEPRICE • LINE_COGS Figure 13: New Tab that Reads Data from the QlikView Expressor Dataflow ReadSalesData Step

Storing and Reusing QlikView Expressions with QlikView Expressor | 11

Save and reload the QlikView application. View the variable Overview panel to see how the variables have been defined.

Figure 14: Variable Overview Showing the Values for the Defined Variables Now these variables can be used just like any other QlikView variables.

Figure 15: QlikView Sheet Object Properties Using the Variables as Expressions, Labels and Comments

Storing and Reusing QlikView Expressions with QlikView Expressor | 12

Figure 16: QlikView Sheet Object Properties Using the Variables in a Title

Figure 17: QlikView Chart Object Configured with Centrally Stored Parameters MODIFY THE CENTRALIZED RULE/EXPRESSION At this point, open the Datascript Module “RulesDSM” and make a modification to an expression – such as: MeasureExpression = ‘Sum (LINEPRICE) * .10’

Figure 18: Modifying the Expressions Save your changes and refresh the deployment package by right clicking and selecting Update. NOTE: You might have to right click on the Deployment Package name and select Refresh Status first to validate the changes and make the Update menu option appear.

Storing and Reusing QlikView Expressions with QlikView Expressor | 13

Figure 19: Update the Deployment Package Reload the QlikView application and note the changes from the modified rule: Before:

Figure 20: Using SUM(LINEPRICE) as Defined Earlier After:

Figure 21: Using SUM(LINEPRICE) * .10 as Modified in One Location

Storing and Reusing QlikView Expressions with QlikView Expressor | 14

Summary Storing and reusing business-logic that increase consistency are essential steps when introducing data governance practices into any organization. With QlikView Expressor, the technique described in this document will allow you to manage common QlikView specific calculations, definitions and expressions from one location; enabling multiple QlikView applications to source a single centralized common set of rules and columns. In addition to this technique, you can also take advantage of the version control repository, data lineage and impact analysis tools that are available in QlikView Expressor Studio. These capabilities allow successful management of your QlikView data and other data assets. Figure 22: The Search Tool Helps Locate Columns Such as LINEPRICE Described in the Code of the RulesDSM Datascript Module

© 2013 QlikTech International AB. All rights reserved. QlikTech, QlikView, Qlik, Q, Simplifying Analysis for Everyone, Power of Simplicity, New Rules, The Uncontrollable Smile and other QlikTech products and services as well as their respective logos are trademarks or registered trademarks of QlikTech International AB. All other company names, products and services used herein are trademarks or registered trademarks of their respective owners. The information published herein is subject to change without notice. This publication is for informational purposes only, without representation or warranty of any kind, and QlikTech shall not be liable for errors or omissions with respect to this publication. The only warranties for QlikTech products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting any additional warranty.

Storing and Reusing QlikView Expressions with QlikView Expressor | 15

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF