Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
qv_testing
Specialist II
Specialist II

Need Help

HI Community,

I am confusing with Mod() function...

Example:

Mod(15,3) is 0 because 15/3 is 5 (5*3=15) with reminder 0  --------------> this is OK

But,

mod( 7.5,2 ) is 1.2 because 7.5/2 is 3 (3*2=6) with reminder 1.5  ------>  but in Qlikview it returns NULL value

and mod( -4,3 )is -1 because  -4/3 is -1 ------> But in Qlikview it returns 2

any Logic here????

Please anyone give explanation...

5 Replies
Anonymous
Not applicable

It is explained in the QV Desktop Help, pasted in below.

mod(x1 , x2)

Mathematical modula function. Both parameters must have integer values. x2 must be greater than 0. The result is the non-negative remainder of an integer division.

Examples:

mod( 7,2 ) returns 1

mod( 7.5,2 ) returns NULL

mod( 9,3 ) returns 0

mod( -4,3 ) returns 2

mod( 4,-3 ) returns NULL

mod( -4,-3 ) returns NULL

qv_testing
Specialist II
Specialist II
Author

Hi Bill,

I Understood this one..


What is the Logic for these two??


Suppose Mod(x1,x2)   here X2  greater than 0.


mod( 7.5,2 ) returns NULL

mod( -4,3 ) returns 2



MarcoWedel

Use fmod() for decimal numbers

Regards

Marco

MarcoWedel

QlikCommunity_Thread_169292_Pic1.JPG

QlikCommunity_Thread_169292_Pic2.JPG

hope this helps

regards

Marco

qv_testing
Specialist II
Specialist II
Author

Hi Wedel,

May be it works like this...

Formula: (Excel Formula)

Mod(A, B) =A - B * Int (A / B)    

Mod(-4,3)  =  -4 -3 * (-2) =2

Suppose INT(A/B) means---->Rounds down

like  INT(8.9) = Rounds 8.9 down= returns 8

INT(-8.9)= Rounds -8.9 down =  returns -9