Modulo Functions in Qlik Sense

Last updated on Nov 15 2021
Praveen Chandra

Table of Contents

Modulo Functions in Qlik Sense

i. Fmod
This function is understood as a generalized modulo function which returns the rest of division happening between two parameters or arguments. within the division, the dividend (a) is split by the devisor (b). All the values, input and output are real values and not integers.
Let’s revise Qlik Sense Interpretation Functions
Syntax:

1. Fmod(a,b)
For example, the subsequent sample values utilized in the functions return the rest values.
fmod( 7,2 ) returns 1
fmod( 7.5,2 ) returns 1.5
fmod( 9,3 ) returns 0
fmod( -5,4 ) returns -1
fmod( 5,-4 ) returns 1
fmod( -5,-4 ) returns -1

ii. Mod
A little different from the fmod() function, the mod() function is that the mathematical modulo function. This function takes in just integers as dividends and divisor and returns the rest values which are positive and integers.
Syntax:

1. Mod(integer_number1, integer_number2)
For example, the subsequent sample values are going to be evaluated by the function and returns the rest as given below,
Mod(7,2) returns 1 because the remainder.
Mod(7.5,2) returns NULL because the dividend isn't an integer.
Mod(9,3) returns 0 because it are going to be the rest .
Mod(5,-4) returns NULL because divisor may be a negative value.
Mod(-5,-4) returns NULL because both the parameters are negative.

Parity Functions in Qlik Sense

i. Even
This function evaluates a worth for whether the given value is a good value or not. If the amount is even or zero, then the function returns True (-1) and if it’s not even, then the function returns False(0). It only takes in integer values and if the worth if not an integer then it returns NULL.
Recommend Reading – Qlik Sense Day Numbering Functions
Syntax:

1. Even(integer_number)
For example, the given sample statements below are going to be checked by this function for being even or not.
Even(3) returns 0, False because 3 is an odd number.
Even(2 * 10) returns -1, True because the multiplication will evaluate to twenty which is even.
Even(3.14) returns NULL because 3.14 isn't an integer.
ii. Odd
This function evaluates a worth for whether the given value is an odd value or not. If the amount is odd, then the function returns True (-1) and if it's not odd, then the function returns False(0). It only takes in integer values and if the worth if not an integer then it returns NULL.
Syntax:
1. Odd(integer_number)
For example, the given sample statements below are going to be checked by this function for being odd or not.
Even(3) returns -1, True because 3 is an odd number.
Even(2 * 10) returns 0, False because the multiplication will evaluate to twenty which is even.
Even(3.14) returns NULL because 3.14 isn't an integer.

Rounding Functions in Qlik Sense

Qlik Sense General Numeric Functions – Rounding Functions
i. Ceil
The ceil() function rounds up a given value to the closest multiple of the amount given shifting it by the offset number mentioned within the function.
You must learn Qlik Sense Mapping Functions
Syntax:
1. Ceil(x[, step[, offset]])
Where, x is that the original input number.
step is that the parameter where you set the closest multiple to which the x should be rounded up. The default is about to be 1. it’s referred to as interval increment. The intervals are counted as …0 < x
offset is that the parameter which sets the bottom of the step interval. the worth set by default is 0.
For example,
Ceil(2.4 ) Returns 3 because the size of the step is 1 and therefore the base of the step interval is 0.
Ceil(4.2 ) returns 5
Ceil(3.88 ,0.1) returns 3.9 where, the dimensions of the interval is 0.1 and therefore the base of the interval is 0.
ii. Floor
As against the Ceil() function, the floor() function rounds down the worth to the closest multiple falling before the integer within the value shifting it by the offset number.
Syntax:
1. floor(x[, step[, offset]])
Where, x is that the original input number.
step is that the parameter where you set the closest multiple to which the x should be rounded up. The default is about to be 1. it’s referred to as interval increment. The intervals are counted as …0 < x
offset is that the parameter which sets the bottom of the step interval. the worth set by default is 0.
For example,
floor(2.4 ) returns 2 because the size of the step is 1 and therefore the base of the step interval is 0.
floor(4.2 ) returns 4.
floor(3.88 ,0.1) returns 3.8 where, the dimensions of the interval is 0.1 and therefore the base of the interval is 0 .
iii. Round
This function rounds a worth up or right down to the closest integer shifting it by an offset number. If a worth is in decimal like 2.5 which is strictly a middle value, then the function will round it upwards.
Syntax:
1. Round(x[, step[, offset]])
Where, x is that the original input number.
step is that the parameter where you set the closest multiple to which the x should be rounded up. The default is about to be 1. it’s referred to as interval increment. The intervals are counted as …0 < x
offset is that the parameter which sets the bottom of the step interval. the worth set by default is 0.
Have a glance at Qlik Sense zone Function
For example,
round(2.5 ) returns 3 because it is rounded up.
round(4.2 ) returns 4. Rounded down.
round(3.88 ,0.1) returns 3.9 where, the dimensions of the interval is 0.1 and therefore the base of the interval is 0 . offset is that the parameter which sets the bottom of the step interval. the worth set by default is 0.
Have a glance at Qlik Sense zone Function
For example,
round(2.5 ) returns 3 because it is rounded up.
round(4.2 ) returns 4. Rounded down.
round(3.88 ,0.1) returns 3.9 where, the dimensions of the interval is 0.1 and therefore the base of the interval is 0 .

Qlik Sense Inter Record Functions

i. Row Functions
So, there are 5 functions in row functions of Qlik Sense Inter Record Functions they’re Above, Below, Bottom, Top, NoOfRows. Let’s discuss these functions intimately –
Qlik Sense Inter Record Functions – Row Functions
a. Above
This function returns a worth which is strictly above the present row and within the same column or field segment. you’ll set the amount of rows above the present row from which you would like to fetch the worth using the offset value.
You must read – Qlik Sense Field Functions
Syntax:

1. Above([TOTAL] expr [ , offset [,count]])

Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter which sets the amount of rows the functions should go up from the present row. The default is about to 1 which fetches the worth from one row just above the present row. If you specify the offset value as a negative value, then the values are fetched from rows below the present row (works like Below function).
Count parameters is employed to return the count of values encountered in each row while rising to the specified row.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example, we’ve sales values of a gaggle of 4 customers. Using the Above() function, we’ll create a replacement field where values from one row up are going to be fetched and in another column, the 2 values are going to be subtracted showing the difference of sales between two customers.

Customer Sales Above(Sales) Sales-Above(Sales)
Rebecca 567
Ethan 680 567 113
Joshua 764 680 84
Mathew 860 764 96

b. Below
This function returns a worth which is strictly below the present row and within the same column or field segment. you’ll set the amount of row below the present row from which you would like to fetch the worth using the offset value.
Syntax:

1. Below([TOTAL] expr [ , offset [,count]])

Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter which sets the amount of rows the functions should go down from the present row. The default is about to 1 which fetches the worth from one row slightly below the present row. If you specify the offset value as a negative value, then the values are fetched from rows above the present row (works like Above function).
Recommended Reading – Qlik Sense String Functions
Count parameters are wont to return the count of values encountered in each row while rising to the specified row.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example, we’ve the sales values of a gaggle of 4 customers. Using the Below() function, we’ll create a replacement field where values from one row down are going to be fetched and in another column, the 2 values are going to be added showing the entire sales of the 2 customers.

Customer Sales Below (Sales) Sales Below (Sales)
Rebecca 567 680 1247
Ethan 680 746 1426
Joshua 764 860 1624
Mathew 860

c. Bottom
The bottom() function returns the bottommost value from the rows of a concerned column.
Syntax:

1. Bottom([TOTAL] expr [ , offset [,count ]])

Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter using which you’ll fetch value, n rows above rock bottom row value. If this value is negative then this function works just like the Top() function.
Count parameters is employed to return the count of values encountered in each row while rising to the specified row.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example, the Bottom(Sales) expression has returned the worth 860 from the bottom-most row.

Customer Sales Bottom(Sales) Sales+Below(Sales)
Rebecca 567 860 1427
Ethan 680 860 1540
Joshua 764 860 1624
Mathew 860 860 1720

What does one realize Qlik Sense Capabilities
d. Top
The top() function returns the worth from the topmost row during a column. This function is simply the other of Bottom() function.
Syntax:

1. Top([TOTAL] expr [ , offset [,count ]])

Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter using which you’ll fetch value, n rows below the highest row value. If this value is negative then this function works just like the Bottom() function.
Count parameters are wont to return the count of values encountered in each row while rising to the specified row.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example, the Top(Sales) expression has returned the worth 567 from the topmost row.

Customer Sales Top(Sales) Sales+Top(Sales)
Rebecca 567 567 1134
Ethan 680 567 1247
Joshua 764 567 1331
Mathew 860 567 1427

e. NoOfRows
This function returns the entire number of rows present during a particular column or field during a table.
Syntax:
1. NoOfRows([TOTAL])
Where, TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example, if a field named ‘Customer’ has 50 rows each having a replacement customer name, then the expression NoOfRows() will return 50 if the present field is Customers.
We recommend you to read – Qlik Sense Data Model
ii. Column Functions

Qlik Sense Inter Record Functions – Column Functions

a. Column
The Column() function returns the values contained during a column using the column number. Only the measure columns or fields are considered by this function and dimensions are completely disregarded.
Syntax:
1. Column(ColumnNo)
Where ColumnNo is that the number of measure column that you simply want to use.
For example,

Customer Year Order Value Total Sales Value %Sales
Rebecca 2017 150 505 29.70
Ethan 2017 64 505 12.67
Joshua 2017 81 505 16.04
Mathew 2017 50 505 9.90

b. Dimensionality
This function returns the dimensionality of a row i.e. the entire number of dimensions that are present during a row. you’ll perform several operations using this function because it may be a convenient thanks to calculate the amount of columns which are dimensions. This function can only be utilized in charts.
Syntax:

1. Dimensionality( )

For example, if a row has three segments from three columns which are dimensions like , ‘Customer’, ‘Product’ and ‘City’ then this function will return 3.
c. Secondarydimensionality
This function is employed to guage the dimensionality of a row within the horizontal pivot table. It works almost like the dimensionality() function and doesn’t include aggregation values. This function returns 0 if it’s used anywhere except in Pivot tables in Qlik Sense.
You must read – Qlik Sense Gauge Chart
Syntax:

1. SecondaryDimensionality( )

Always an integer value is returned.
iii. Field Functions

Qlik Sense Inter Record Functions – Field Functions
a. FieldIndex
The FieldIndex() function returns the index value or position of a worth during a given field. this is often referred to as indexing of field values. This function returns an integer value.
Syntax:

1. FieldIndex(field_name , value)

Where, field_name is that the name of the sector during a particular table.
value is that the field value whose position within the field or column you would like to urge as an index value.
For example, within the script given below, there are certain fields loaded having a series of values.

1. Names:
2. LOAD * inline [
3. "FirstName"|"LastName"|”Initials”|"HasCellphone"
4. Jay|Verma|JV|Yes
5. Sushmita|Bisht|SB|Yes
6. Mrinal|Thakur|MT |No
7. Praveen|Deshpande|PD|No
8. Jiva|Singh|JS|Yes
9. Purvi|Fadnavis|PF|Yes ] (delimiter is '|');

We can obtain the index values for specific field values. as an example , the expression,
• FieldIndex(‘FirstName’,’Jay’) returns 1 because Jay is that the first value within the field FirstName.
• FieldIndex(‘LastName’,’Deshpande’) returns 4.
• Position1:
Load FieldIndex(‘FirstName’,’Purvi’) as Position
1. Resident Names;
Returns, Position=6.
• Position2:
Load FieldIndex(‘FirstName’,’Mrinal’) as MrinalPosition
1. Resident Names;
Returns, MrinalPosition=3.
b. FieldValue
This function is that the inverse of the FieldIndex() function. This function returns the worth during a field from the given index or position of the worth within the field counted from top to bottom.
Syntax:
1. FieldValue(field_name , elem_no)
Where, field_name is that the name of the sector during a particular table.
Element_no is that the position of the worth that you simply want to fetch counted within the load order during a field.
For example, within the script given below, there are certain fields loaded having a series of values.

1. Names:
2. LOAD * inline [
3. "FirstName"|"LastName"|”Initials”|"HasCellphone"
4. Jay|Verma|JV|Yes
5. Sushmita|Bisht|SB|Yes
6. Mrinal|Thakur|MT |No
7. Praveen|Deshpande|PD|No
8. Jiva|Singh|JS|Yes
9. Purvi|Fadnavis|PF|Yes ] (delimiter is '|');

We can obtain the values like particular index position values. as an example , the expression,
• FieldValue(‘FirstName’,’1′) returns Jay, because Jay is that the first value within the field FirstName.
• FieldValue(‘LastName’,’4′) returns ‘Deshpande’.
• Position1:
Load FieldValue(‘FirstName’,’6′) as Position
Have a glance at Box Plot in Qlik Sense Visualization
1. Resident Names;
Returns, Position=Purvi.
• Position2:
Load FieldValue(‘FirstName’,’3′) as MPosition
1. Resident Names;
Returns, MPosition=Mrinal.
c. FieldValueCount
This function returns the count or total number of values during a specific field.
Syntax:
1. FieldValueCount(field_name)
Where, field_name is that the name of the sector during a particular table.
For example, within the code given below, we will use this function to count the entire values in one among the fields.

1. Names:
2. LOAD * inline [
3. "FirstName"|"LastName"|”Initials”|"HasCellphone"
4. Jay|Verma|JV|Yes
5. Sushmita|Bisht|SB|Yes
6. Mrinal|Thakur|MT |No
7. Praveen|Deshpande|PD|No
8. Jiva|Singh|JS|Yes
9. Purvi|Fadnavis|PF|Yes ] (delimiter is '|');

We can use this function to calculate the entire values in any of the fields uploaded within the table, such as, ‘FirstName’, ‘LastName’, ‘Initials’, ‘HasCellphone’.
FieldValueCount(‘FirstName’) returns 6 as there are six values within the field FirstName.
Similarly, the function FirstValueCount(‘LastName’) returns 6.
iv. Pivot Table Functions
Qlik Sense Inter Record Functions – Pivot Table Functions
a. After
This function evaluates the worth s during a row horizontally and returns the value present after or to the proper of a currently selected cell.
Syntax:
1. after([TOTAL] expr [, offset [, count ]])
Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter using which you’ll fetch value, n rows further the present row. If this value is negative then this function works just like the Before() function.
Recommended Reading – Qlik Sense Treemap Visualization
Count parameters are wont to return the count of values encountered while moving n rows further as specified by the count parameter.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example,

1. Names:
2. LOAD * inline [
3. "FirstName"|"LastName"|”Initials”|"HasCellphone"
4. Jay|Verma|JV|Yes
5. Sushmita|Bisht|SB|Yes
6. Mrinal|Thakur|MT |No
7. Praveen|Deshpande|PD|No
8. Jiva|Singh|JS|Yes
9. Purvi|Fadnavis|PF|Yes ] (delimiter is '|');

When you use this function like,
After(FirstName) returns the values from the column ‘LastName’ because it lays right to the FirstName column.
b. Before
This function evaluates the worth s during a row horizontally and returns the value present before or to the left of a currently selected cell.
Syntax:
1. Before([TOTAL] expr [, offset [, count ]])
Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter using which you’ll fetch value, n rows behind or to the left of the present row. If this value is negative then this function works just like the After() function.
Count parameters are wont to return the count of values encountered while moving n rows backward as specified by the count parameter.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example,

 
1. Names:
2. LOAD * inline [
3. "FirstName"|"LastName"|”Initials”|"HasCellphone"
4. Jay|Verma|JV|Yes
5. Sushmita|Bisht|SB|Yes
6. Mrinal|Thakur|MT |No
7. Praveen|Deshpande|PD|No
8. Jiva|Singh|JS|Yes
9. Purvi|Fadnavis|PF|Yes ] (delimiter is '|');

When you use this function like,
Before(LastName) returns the values from the column ‘FirstName’ because it lays before or left to the LastName column.
c. First
This function returns the primary value within the column of the present row. This function can only be utilized in a pivot table.
Syntax:
1. first([TOTAL] expr [, offset [, count]])
Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter using which you’ll fetch value, n rows further or to the proper of the present cell. If this value is negative then this function works just like the Last() function.
Count parameters is employed to return the count of values encountered while moving n rows further as specified by the count parameter.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example, the expression, first(FirstName) will return Jay because it is that the first value of the primary row within the table. (refer to the sample data loaded within the functions above).
d. Last
This function returns the last value within the column of the present row. This function can only be utilized in a pivot table.
Let’s discuss more in Qlik Sense Table Functions
Syntax:

1. last([TOTAL] expr [, offset [, count]])

Where, expr is that the dimension or field name from which we would like to fetch the record values.
Offset is that the parameter using which you’ll fetch value, n rows further or to the left of the present cell. If this value is negative then this function works just like the First() function.
Count parameters is employed to return the count of values encountered while moving n rows further towards the left as specified by the count parameter.
TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
For example,

 
1. Names:
2. LOAD * inline [
3. "FirstName"|"LastName"|”Initials”|"HasCellphone"
4. Jay|Verma|JV|Yes
5. Sushmita|Bisht|SB|Yes
6. Mrinal|Thakur|MT |No
7. Praveen|Deshpande|PD|No
8. Jiva|Singh|JS|Yes
9. Purvi|Fadnavis|PF|Yes ] (delimiter is '|');

The expression, last(FirstName,0,4) will return four values from the last row i.e. Purvi, Fadnavis, PF, Yes.
e. ColumnNo
This function returns the entire number of columns present during a particular row (upon evaluating horizontally).
Syntax:

1. ColumnNo([total])

Where, TOTAL may be a qualifier when used (in the one-dimensional table) returns the present value to be adequate to all the values within the entire column.
The columns during a row are counted from 1 for the primary row then on for the column segments to follow.
For example, if we would like the column number of a row, we use this function as ColumnNo() then you’ll get 4 because the column numbers for the table ‘Names’ (given in functions above).
v. Data Load Script Functions
Qlik Sense Inter Record Functions – Data Load Script Functioons
a. Exists
This function checks whether a worth exists during a field or in other words, has been loaded into the script or not. If yes, then it returns -1 or True and if no, then this function returns 0 or False because the Boolean values. Such results are often further utilized in Where or If statements within the script.
Syntax:

1. Exists(field_name [, expr])

Where, field_name is that the name of the sector or column you would like to seem up the worth in.
expr is that the value which you would like to see exists or not.
For instance, the expression exists(FirstName, ‘Gaurav’) will return -1, True if the info load script contains Gaurav within the records alternatively 0, False are going to be returned by this function.
What is the utilization of Trigonometric and Hyperbolic Functions in Qlik Sense
b. LookUp
This function searches or looks up for a worth present during a specific field during a currently or previously loaded script.
Syntax:

1. lookup(field_name, match_field_name, match_field_value [, table_name])

Where, field_name is that the name of the sector that you would like to lookup surely values. you want to write this in single-quoted string literals.
Match_field_name is that the name of the sector whose value you would like to seek out and match with the opposite field. This parameter should even be enclosed as quotes literals.
Match_field_value is that the specific field value you’re trying to find .
Table_name is that the name of the table you would like to look the worth in.
For example, the expression, Lookup(‘Category’, ‘ProductID’, ProductID, ‘ProductList’) as CategoryID will fist evaluate the values from the sector ‘Category’ then match it with the values of ‘ProductID’ from the table ProductList and return the leads to the sector CategoryID.
c. Peek
This function finds and returns a worth of a field from a selected row. The row number and table name are often laid out in the function itself. The tables that this function searches certain values are either currently loaded within the script or the values exist already within the internal storage.
Syntax:

1. Peek(field_name[, row_no[, table_name ] ])

Where, field_name is that the name of the sector that you would like to seek out values during a row of a field. you want to write this in single-quoted string literals.
Row_no is that the specific number of row that you simply want like , 0 for the primary record, 1 for the second then on. If you employ a negative number, then the values are going to be evaluated from bottom to top direction.
Table_name is that the name of the table consisting of the concerned fields.
d. Previous
This function returns the info values from previous records, probably residing during a different table.
Syntax:

1. Previous(expr)

Where expr is that the previous field from which you would like to fetch values during a current table.
So, this brings us to the end of blog. This Tecklearn ‘Modulo Functions in Qlik Sense’ 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 "Modulo Functions in Qlik Sense"

Leave a Message

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