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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
sarfaraz_sheikh
Contributor III
Contributor III

Show 0 when value is negative in front end

Dear Folks,

i have the below expression and I want to print 0 when values is negative.


Expression : Sum({<NumDateKey={">=$(=vFromDate)<=$(=vToDate)"}>} [9LE Bulk Vol])


If above Expression gives -16.5 or 0 then show me 0 else show me actual value or 1.

I can Achieve this by using  below expression. But i dont want to use If function as it will take long time to process the data in front end end. I wanted to achieve this without If condition...

If( Sum({<NumDateKey={">=$(=vFromDate)<=$(=vToDate)"}>} [9LE Bulk Vol])  <=0,0,1)


Also, I can't do it in back end also like below because it is running on dynamic date selection based on user input

If(  [9LE Bulk Vol] <=0,0,1)

Suppose user Select 15-04-2018  then  from_date and To_date is calculated like below . And every time user will select different date and based on that user input the expression will give the result and on that result we have to implement if negative value then 0 else 1.  

From_date = (15-04-2018) -91  = 14-01-2018

To_date =  15-04-2018

So expression becomes like this

Sum({<NumDateKey={">=(14-01-2018)<=(15-04-2018)"}>} [9LE Bulk Vol])


Can anybody tell me how we can achieve whithout If condition in front end . help would be much appreciated.

Thanks

Sarfaraz

3 Replies
Digvijay_Singh

I think you should go with 'If', IF is not inside Sum, so will be executed only once after Sum calculation. It degrades performance when data volume is high, used inside SUM and executed for each row.

tamilarasu
Champion
Champion

Hi Sarfaraz,

If you want to show actual value as it is and negative value as 0 then try

RangeMax(0,Sum({<NumDateKey={">=$(=vFromDate)<=$(=vToDate)"}>} [9LE Bulk Vol]))


If you want to show 1 for actual values and negative value as 0, this looks silly but you can try,


Fabs(Sum({<NumDateKey={">=$(=vFromDate)<=$(=vToDate)"}>} [9LE Bulk Vol])>0)

vishsaggi
Champion III
Champion III

May be try like

= RangeMax(Sum({<NumDateKey={">=$(=vFromDate)<=$(=vToDate)"}>} [9LE Bulk Vol]), 0)