Qlik Sense Counter and Exponential and Logarithmic Functions

Last updated on Nov 16 2021
Darayus Lamba

Table of Contents

Qlik Sense Counter and Exponential and Logarithmic Functions

 Counter Functions in Qlik Sense

i. autonumber() in Qlik Sense

The autonumber() function assigns an integer value to each unique record encountered during script execution. this is often done to store large data records into compact composite keys where integer values are assigned to distinct record values as per the expression laid out in autonumber function.
The syntax for Qlik Sense aurtonumber function –
1. autonumber(expression[ , AutoID])
where expression is that the record names that you simply want to form composite keys for using autonumber.
Basically, the AutoID is an optional parameter or an ID that you simply can assign to individual autonumber counters just in case you’re creating quite one within the same script.
For example, we’ve created a composite key for the records of combination of the fields Region, Year and Month.
RegionSales in Qlik Sense autonumber:

1. LOAD *,
2. AutoNumber(Region&Year&Month) as RYMkey;
3. LOAD * INLINE
4. [ Region, Year, Month, Sales
5. North, 2017, May, 245
6. North, 2017, May, 347
7. North, 2017, June, 127
8. South, 2017, June, 645
9. South, 2018, May, 367
10. South, 2018, May, 221
11. ];

So, this composite key will assign integers to the records of the table we loaded inline.
Have a glance at Qlik Sense Histogram Visualization

Region Year Month Sales RYMkey
North 2017 May 245 1
North 2017 May 374 1
North 2017 June 127 2
South 2017 June 645 3
South 2018 May 367 4
South 2018 May 221 4

As you’ll see within the table, for every new combination of region, year and month, there’s a singular RYMkey. Such RYMkeys are the composite keys made using autonumber() function. So, we use these keys further within the script when values like the keys use during a calculation. for instance , using the RYMkey values, the sales values like each RYM combination are often utilized in some calculations like sum, average etc.

ii. autonumberhash128() in Qlik Sense

The autonumberhash128() may be a variation of the autonumber() function we learned earlier. Autonumber only created an integer value because the composite key and assigned it to combination of vales but autonumberhash128() first creates a 128-bit hash value for the mixture then assigns an integer number like each hash value. We create such values to store large and sophisticated keys in less memory space and simpler forms.
Let’s discuss Selections in Qlik Sense
The syntax for Qlik Sense Counter Function autonumebrhash128
1. autonumberhash128(expression {, expression})
Please note that such we will only create hash values if we use it within the same data load script. If you would like to use the composite keys made using autonumberhash128() in another load script then you want to use functions like hash128, hash160, and hash256.
Anyway, to know this function better, we load a sample data inline then create a hash value composite key using autonumberhash128() function. during this sample code, we’ve created a composite key called RYMkey which can assign unique 128-bit hash values to the region, year and month combinations.
RegionSales in autonumberhash128

1. LOAD *,
2. AutoNumberHash128(Region, Year, Month) as RYMkey;
3. LOAD * INLINE
4. [ Region, Year, Month, Sales
5. North, 2017, May, 245
6. North, 2017, May, 347
7. North, 2017, June, 127
8. South, 2017, June, 645
9. South, 2018, May, 367
10. South, 2018, May, 221
11. ];

This will end in composite keys like unique combinations of region, year and month.

Region Year Month Sales RYMkey
North 2017 May 245 1
North 2017 May 374 1
North 2017 June 127 2
South 2017 June 645 3
South 2018 May 367 4
South 2018 May 221 4

Now, using these RYMkey values like use 2 if you would like to use the mixture North, 2017, June. within the code given below, we’ve used the composite key we’ve created to load a replacement field ‘Costs’.

RegionCosts:

1. LOAD Costs,
2. AutoNumberHash128(Region, Year, Month) as RYMkey;
3. LOAD * INLINE
4. [ Region, Year, Month, Costs
5. South, 2018, May, 167
6. North, 2017, May, 56
7. North, 2017, June, 199
8. South, 2017, June, 64
9. South, 2018, May, 172
10. South, 2018, May, 126
11. ];

Now, the sales and Costs fields are automatically linked depending upon the RYM combination they’re sharing. as an example , notice within the table below, that shows sum of costs and sales for every unique RYM combination.

Region Year Month Sum([Sales]) Sum([Costs])
Totals 1952 784
North 2017 June 127 199
North 2017 May 592 56
South 2018 June 645 64
South 2018 May 588 465

iii. autonumberhash256()

The autonumberhash256() function creates a 256-bit value for unique composite keys made for distinct combinations of knowledge records or value. Like, Europe, 2017, January are often one combination of knowledge records that first a 256-bit hash value will create then an integer will assign thereto . very similar to all the opposite autonumber function, this is often also we use to manage system’s space by handling complex keys through making such composite keys. This also prevents from the formation of the synthetic key.
Do you realize Qlik Sense Filter Pane
Syntax for autonumberhash256
1. autonumberhash256(expression {, expression})
The expressions are the fields from the info record that you would like to make a 256-bit hash.
For instance, if we use an equivalent data set that we’ve used while explaining autonumberhash128() function, then the code will appear as if ,
RegionSales in Qlik Sense Counter Functions autonumberhash256

1. LOAD *,
2. AutoNumberHash256(Region, Year, Month) as RYMkey;
3. LOAD * INLINE
4. [ Region, Year, Month, Sales
5. North, 2017, May, 245
6. North, 2017, May, 347
7. North, 2017, June, 127
8. South, 2017, June, 645
9. South, 2018, May, 367
10. South, 2018, May, 221
11. ];

This will create 256-bit hash values and integer values like the Region, Month and Year combinations the function encounters while executing the script. Like,
• RYMkey 1 for North, 2017, May
• RYMkey 2 for North, 2017, June
• RYMkey 3 for South, 2017, June
• RYMkey 4 for South, 2018, May
Also, there’ll be unique 256-bit hash values for the key numbers 1,2,3 and 4 stored within the system.

iv. InterNo() in Qlik Sense

The InterNo() function is employed to mark or number iterations or number of times an expression is being executed during a loop. Like, the primary execution are going to be marked as 1, second as 2 then on until the loop is terminated.
Let’s revise Qlik Sense Key Concepts
The syntax for InterNo function:
1. InterNo()
Let us understand this through an example. Suppose we’ve a code as below.

1. LOAD
2. IterNo() as Day,
3. Date( StartDate + IterNo() - 1 ) as Date
4. While StartDate + IterNo() – 1
5. LOAD * INLINE
6. [StartDate, EndDate
7. 22-01-2018, 26-01-2018
8. ];

This code will generate iterations for every time the loop is executed ranging from the beginning date and ending on the top date as laid out in the Load Inline statement. The repetitions are going to be numbered within the field Day. it’s recommended to use the InterNo() function with While clause because it works best in loops.
The above code will generate a table as a result.

Day Date
1 22-01-2018
2 23-01-2018
3 24-01-2018
4 25-01-2018
5 26-01-2018

This shows that the InterNo() function has created numbers for every time the while loop got executed through the LOAD statement and has stored them because the values of the sector , Day. you’ll use this function for larger data values because it automatically creates number through loop saving the time to manually roll in the hay .
You must examine Qlik Sense capabilities

v. RecNo() in Qlik Sense

The RecNo() function returns the amount of record as per each record’s order within the LOAD script. Like, the primary record that’s read during script execution are going to be numbered 1, then subsequent as 2 then on
The syntax for Qlik Sense Counter Functions RecNo:
1. RecNo()
For example, we load some data inline through the info load script. we’ll call this data table load.

Table1:
1. LOAD * INLINE
2. [A, B
3. 1,cc
4. 2,dd
5. 3,ee];
Table2:
1. LOAD * INLINE
2. [C, D
3. 4, xx
4. 5,yy
5. 6,zz];

Now, using RecNo() we’ll load record numbers of the entries in both the tables loaded above.

QTab:

1. LOAD *,
2. RecNo( ),
3. resident Table1 where A2;
4. LOAD
5. C as A,
6. D as B,
7. RecNo( ),
8. resident Table2 where A4;

//We don’t need the source tables anymore, so we drop them
Do you realize Qlik Sense Box Plot Visualizations
1. Drop tables Table1, Table2;
Here, we don’t want the record number 2 and 4 from each table. So, the resultant table would be,

A B RecNo()
1 cc 1
3 ee 3
5 yy 2
6 Zz 3

If you notice carefully, you’ll observe the record numbers consistent with the load order within the rawscript and not as they seem within the table.

vi. RowNo()

The RowNo() function returns the numbering for rows within the internal Qlik Sense table made by loading data into data load script. this is often different from RecNo() function because it returns the numbering of rows when a table remains within the load script in raw form and not within the resultant table.
The syntax for Qlik Sense Counter Functions RowNo:
1. RowNo([TOTAL])
Let us take an equivalent example that we did within the RecNo() function explanation.
Table1:

1. LOAD * INLINE
2. [A, B
3. 1,cc
4. 2,dd
5. 3,ee];
Table2:
Let’s discuss the way to create Qlik Sense Applications
1. LOAD * INLINE
2. [C, D
3. 4, xx
4. 5,yy
5. 6,zz];

Now, we’ll create an indoor table where we number the rows using RowNo().

QTab:

1. LOAD *,
2. RowNo( ),
3. resident Table1 where A2;
4. LOAD
5. C as A,
6. D as B,
7. RowNo( ),
8. resident Table2 where A4;

//We don’t need the source tables anymore, so we drop them
1. Drop tables Table1, Table2;
The table created will appear as if this,

A B RowNo()
1 cc 1
3 ee 2
5 yy 3
6 Zz 4

Qlik Sense Exponential and Logarithmic Functions

i. exp() function

The exp() function is employed to calculate the exponential value of an integer. It uses the Napierian logarithm e base which is that the mathematical constant in ex. While using the exponential , you simply got to specify the worth for x.
Have a glance at Qlik Sense Histogram Visualization
The syntax of exp() function
1. exp(x)
Where x is that the number you would like to convert as an exponential value calculated upon the bottom e. The results of this function may be a positive number.
For example,
exp(3) returns 20.085.

ii. log() function

This function gives the Napierian logarithm of x where x>0.
The syntax for log() function:

1. log(x)
For example,
log(3) returns 1.0986

iii. log10() function

This function returns the worth of common logarithmic base 10 of x, where x>0 and may be a number.
The syntax for log10() Function:

1. log10(x)
For example,
log10(3) returns 0.4771

Do you realize Qlik Sense Data Model

iv. pow() function

This function is employed to guage x to the facility y for any two numbers as x and y. the amount within the place of x are going to be the bottom number and y
The syntax for pow() Function:

1. pow(x,y)
For example,
pow(3, 3) returns 27, or
pow(3, 2) returns 9

v. sqr() function

This function returns the results of x squared i.e. x2 (x to the facility 2).
The syntax for sqr() Function:

1. sqr(x)
For example,
sqr(3) returns 9
sqr(4) returns 16
Let’s revise Qlik Sense Selections

vi. sqrt() function

The sqrt() function calculates the root of numbers. The x may be a number which should be greater than 0 and therefore the function returns a positive number.
The syntax for sqrt() function:

1. sqrt(x)
For example,
sqrt(2) returns 1.414
sqrt(3) returns 1.732
sqrt(9) returns 3

So, this brings us to the end of blog. This Tecklearn ‘Qlik Sense Counter and Exponential and Logarithmic Functions’ blog helps you with commonly asked questions if you are looking out for a job in Qlik Sense BI. If you wish to learn Qlik Sense and build a career in Business Intelligence domain, then check out our interactive, Qlik Sense 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-sense-certification-training/

Qlik Sense Certification Training

About the Course

Qlik Sense is a revolutionary Business Analytics tool to come from the Qlik stables. It provides powerful self-service analytics that are readily deployable through interactive and personalized dashboards, data visualization techniques and insightful reports. By the end of this Qlik Sense online training, you will be able to perform key skills of the self-service BI tool – Qlik Sense, such as self-service analytics, write data load scripts, data discovery, create dashboards, develop and share apps, create reports, and design and build data visualizations. All these skills will enable you to clear the Qlik Sense certification exam.

Why should you take Qlik Sense Training?

  • The average annual pay for a Qlik Sense Professional is $101,871. -Indeed.com.
  • HSBC, Alstom, Chrysler, Citibank, Accenture and many other MNC’s worldwide use Qlik Sense BI and it has a market share of around 5% globally.
  • By the end of 2020, the market is expected to touch USD 22.8 billion as modern BI and analytics continue to expand more rapidly, Gartner said in a report.

What you will Learn in this Course?

Introduction and Installation of Qlik Sense

  • Need for self-service Business Intelligence/Business Analytics
  • Installation of Qlik Sense and Qlik Sense Desktop

Qlik Sense Features

  • Qlik Data indexing engine
  • Data dimensions relationships
  • Types of Data Loading
  • Types of Concatenation

Data Modelling

  • Qlik Sense data architecture
  • Understanding QVD layer
  • Converting QlikView files to Qlik Sense files
  • Incremental Load
  • Scripting
  • Create Master Calendar

Advance Data Modelling

  • Qualify and unqualify
  • Joins
  • Keep
  • Cross Table
  • Let Vs Set
  • Calendar Table Creation

Qlik Sense Enterprise

  • Various Functions
  • Create QVD Files
  • Read Data for QVD Files
  • Create QVD’s
  • Create Tier 2 Qlik Sense App

Data Visualization

  • Expressions
  • Variables
  • Extensions
  • Data Visualization

Set Analysis

  • Set analysis in Qlik Sense
  • Use set expression like identifiers, operators, modifiers and comparative analysis

Advance Set Analysis

  • Deploy comparison sets and perform point-in-time analysis

Qlik Sense Storytelling

  • Storytelling feature of Qlik Sense
  • Create a story and playback the story

Qlik Sense Visualization

  • Qlik Sense Charts
  • Advanced Charts
  • Creating Dashboards
  • Real Life Examples

Security

  • Security aspects of Qlik Sense
  • Security rules

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

0 responses on "Qlik Sense Counter and Exponential and Logarithmic Functions"

Leave a Message

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