2 Replies Latest reply: Jun 21, 2016 11:48 AM by Imran Khan RSS

    Why Today() is better than Now() on front end expressions

    Steve Lord

      So I have this nprinting project where I want nprinting to be able to just cycle through clients and grab numbers at face value.  I am writing expressions in qlikview that look at activity through the end of 'last month'.

       

      I'm used to using now() on load scripts where I want to filter out (or isolate) stuff with erroneous dates from the future, but using now() on front end expressions kept my CPU running at 99-100% and the little calculation bars kept flickering up and down my numbers without changing the numbers.  It dawned on me that this expression was recomputing now() as fast as the timestamp for now() changed.

      =count(distinct if(

      ((date(floor([PSQ Completed Date])))>=(date(floor(CurrentPYStart))))

      AND

      ((year([PSQ Completed Date])&num(month([PSQ Completed Date]),'00'))<(year(Now())&num(month(Now()),'00')))//through last month

      ,UserId))

       

      I resolved by switching from now() to today() - the nonstop recalculation halted after one quick calculation for today().

      =count(distinct if(

      ((date(floor([PSQ Completed Date])))>=(date(floor(CurrentPYStart))))

      AND

      ((year([PSQ Completed Date])&num(month([PSQ Completed Date]),'00'))<(year(Today())&num(month(Today()),'00')))//through last month

      ,UserId))

       

      Just wanted to share in case anyone else had such an issue.  It's invisible on small sets of test data I had, but was frightening with large sets of data. Couple hours of my life I'd like back.

       

      (These formulas are among 20 or so designed to just produce final counts of various things, and I have nprinting placing them on a raw data tab of an excel spreadsheet.  Another finished graphic/design heavy tab of the excel file takes in the raw data and we save that finished page as a pdf.  QV and Nprinting are awesome, but reporting people liked the graph designs from ms office and such a little more, so I just get numbers onto their files for them. )