Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

"if" greater or less than in expression

Hey.

I would like to script the following:

if(sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) >=3000 ,Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount), '0'

or

if(Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) <=-3000 ,Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount),'0'))

What I'm trying to achieve is to have my pivot table display the sum(amount) where, sum(amount) is >=3000 or <=  -3000.

at present the above expression only returns the >=3000 part the of expression.

could someone please point me in the right direction

Thanks

Bon

1 Solution

Accepted Solutions
maxgro
MVP
MVP

if(sum(Amount)>=3000 or sum(Amount)<=-3000, sum(Amount),0)

replace sum(Amount) with your expression

View solution in original post

3 Replies
MK_QSL
MVP
MVP

use and instead of or

if(sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) >=3000 and

Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) <=-3000 ,

Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount),0)

Check the number of opening and closing brackets...

maxgro
MVP
MVP

if(sum(Amount)>=3000 or sum(Amount)<=-3000, sum(Amount),0)

replace sum(Amount) with your expression

Anonymous
Not applicable
Author

Thanks Massimo and Manish.

correct expression was OR, using AND returned 0.

if(sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) >=3000 or

Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount) <=-3000 ,

Sum({<Year=,Month=, Date={'>=$(vYTDStart)<=$(vYTDEnd)'}>}Amount),'0')