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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Timotix
Contributor II
Contributor II

shorter if-statement with range filter

Hello all,

I am currently working on a table where the user can filter the results based on the values of the result.
The user has following three buttons:

  1. >0% <10% (vShowRed)
  2. >10% <30% (vShowYellow)
  3. >30% (vShowGreen)

So if a variable is set to '0' the values should be null() and not displayed. Currently I have following formula which is working but I have a feeling that there is a way more easier way.

 

if($(vShowRed) = 1 and $(vShowYellow) = 1 and $(vShowGreen) = 1,                                            ($(vResult)),
if($(vShowRed) = 1 and $(vShowYellow) = 1 and $(vShowGreen) = 0, if( $(vResult) < 0.3,                       $(vResult)),
if($(vShowRed) = 1 and $(vShowYellow) = 0 and $(vShowGreen) = 1, if( $(vResult) < 0.1 or $(vResult) >= 0.3,  $(vResult)),
if($(vShowRed) = 1 and $(vShowYellow) = 0 and $(vShowGreen) = 0, if( $(vResult) < 0.1,                       $(vResult)),
if($(vShowRed) = 0 and $(vShowYellow) = 1 and $(vShowGreen) = 1, if( $(vResult) >= 0.1,                      $(vResult)),
if($(vShowRed) = 0 and $(vShowYellow) = 1 and $(vShowGreen) = 0, if( $(vResult) >= 0.1 and $(vResult) < 0.3, $(vResult)),
if($(vShowRed) = 0 and $(vShowYellow) = 0 and $(vShowGreen) = 1, if( $(vResult) >= 0.3,                      $(vResult)),
($(vResult))
))))))))

 

 Thank you guys for the support. 🙂

Labels (2)
1 Solution

Accepted Solutions
Timotix
Contributor II
Contributor II
Author

I figured something out by myself:

=
if($(vResult) < 0.1,if($(vShowRed) = 1,$(vResult),null())
,if($(vResult) < 0.3,if($(vShowYellow) = 1,$(vResult),null())
,if($(vResult) >= 0.3,if($(vShowGreen) = 1,$(vResult),null())
)))

View solution in original post

1 Reply
Timotix
Contributor II
Contributor II
Author

I figured something out by myself:

=
if($(vResult) < 0.1,if($(vShowRed) = 1,$(vResult),null())
,if($(vResult) < 0.3,if($(vShowYellow) = 1,$(vResult),null())
,if($(vResult) >= 0.3,if($(vShowGreen) = 1,$(vResult),null())
)))