Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Nagaraju_KCS
Specialist III
Specialist III

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...

Labels (1)
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

Nagaraju_KCS
Specialist III
Specialist III
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
MVP
MVP

Use fmod() for decimal numbers

Regards

Marco

MarcoWedel
MVP
MVP

QlikCommunity_Thread_169292_Pic1.JPG

QlikCommunity_Thread_169292_Pic2.JPG

hope this helps

regards

Marco

Nagaraju_KCS
Specialist III
Specialist III
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