Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
hopkinsc
Partner - Specialist III
Partner - Specialist III

Help with displaying whole numbers

Hi,

I have a straight table with an expression which basically just divides SALESQUANTITY by 3. I would like QLIKVIEW to only display the results for this expression if they are whole numbers, i.e.

If the results show

1.333

.333

4

2

.333

I only want the 4 and 2 to be displayed and the others hidden.

Is this possible?

8 Replies
Or
MVP
MVP

Try:

If(SalesQuantity/3 = floor(SalesQuantity/3),SalesQuantity/3)


hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

That seems to have hidden everything...

any ideas?

Or
MVP
MVP

A cleaner version of the same would be:

if(frac(SalesQuantity/3)=0,SalesQuantity/3)

or

if(mod(SalesQuantity,3)=0,SalesQuantity/3)

Play around with the floor(), frac(), and mod() functions until you find something that works.

jagan
Luminary Alumni
Luminary Alumni

HI,

Try this, it is working fine

I created a temp table like this

Test:

LOAD * INLINE [
No, Sales
1, 466654.5
2, 53.45
3, 55
4, 44
5, 33
6, 85
7, 24.2
8, 24
];

and used the expression as below

if(Sales/3 = floor(Sales/3), Sales/3)

The straight table displays the No. 5 & 8 rows.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Mod() can take only integers as parameters. Instead you can go for fmod.

if(fmod(SalesQuantity, 3) = 0, SalesQuantity/3)

Regards,

Jagan.

brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi,

mod(Sales,3) is here the best way, and yes, 3 is an integer, Sales must not be an integer!

hopkinsc
Partner - Specialist III
Partner - Specialist III
Author

Sorry, i think i understand why this isn't working for me, it needs to be the sum of sales quantity, not just sales quantity.

How would i do this?

Not applicable

You could you this

if ( mod ( Sales ,1) = 0 , Sales, '')