Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
mendoncart
New Contributor III

How to limit a value between two numbers?

Hi everyone!

I've searched enough and so far, no results.

I want a function to limit the values of an expression.

Like so:

If the result is greater than 1, keep 1. If the result is less than -1, keep -1. If the result is anything between these two values, keep the result.

I cant use if function, because my expression is too large and I would've to put it on the logic test part, and repeat it on the true or false argument, and qliksense doesn't allow this much characters.

Any thoughts?

Thaks!

1 Solution

Accepted Solutions
Not applicable

Re: How to limit a value between two numbers?

What about:

=rangemin(rangemax('Your Expression', -1), 1)

4 Replies
Not applicable

Re: How to limit a value between two numbers?

What about:

=rangemin(rangemax('Your Expression', -1), 1)

beck_bakytbek
Honored Contributor

Re: How to limit a value between two numbers?

Hi Mendonca,

you can use in your case: Flags

if(yourField >1, 2,

if(yourField <1, 3,0) as Flag_Field,

and on your app:

you can use thies : Dim: YourField,

Expression: Sum({<Flag_Field= {'2'}>}YourField) for >1

Expression: Sum({<Flag_Field= {'3'}>}YourField) for < 1

i hope that helps

Beck

MVP & Luminary
MVP & Luminary

Re: How to limit a value between two numbers?

The following should be working for your mentioned conditions:

= pick(match(floor(result), 1, -2, 0, -1), 1, -1, result, result)

- Marcus

mendoncart
New Contributor III

Re: How to limit a value between two numbers?

Thank you all for the attention!