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: 
upaliwije
Creator II
Creator II

Calculation

Hi Friend

I have follwing script to load data in my QV doc.

LOAD Month_Year,

     POLICY_NO,

    // REF_NO,

     TRN_DATE,

     PERIOD_FROM,

     PERIOD_TO,

  ( PERIOD_TO - PERIOD_FROM)+1 as INTERVAL,

     NRP

       NRP/( PERIOD_TO - PERIOD_FROM)+1 AS NRP_PD,

         

FROM

(biff, embedded labels, table is [Correct (2)$]);

Resulting out put is like a shown  below

         

POLICY_NOTRN_DATEPERIOD_FROMPERIOD_TOINTERVALMonthEndBAL_DAYSBAL_DAYS1NRPNRP_PD
1007/7/20173/22/20171/21/2018306.07/31/201724.0132.0-12,855.72-41.15

Here the NRP_PD value is only -41.15 but if I divide NRP/INTERVAL (-12855.72/306) it is 42.01

I can not understand the how two figures differ. Can some one help me to arrive at 42.01 from my QV calculation also.

1 Solution

Accepted Solutions
niclaz79
Partner - Creator III
Partner - Creator III

Hi,

Your mistake is here:

NRP/( PERIOD_TO - PERIOD_FROM)+1 AS NRP_PD,


What you need to write is:

NRP/(( PERIOD_TO - PERIOD_FROM)+1) AS NRP_PD


Otherwise the +1 is not added to the interval value and is added after the division instead.


What you had was:

-12855.72/305+1 = -41.15

View solution in original post

2 Replies
niclaz79
Partner - Creator III
Partner - Creator III

Hi,

Your mistake is here:

NRP/( PERIOD_TO - PERIOD_FROM)+1 AS NRP_PD,


What you need to write is:

NRP/(( PERIOD_TO - PERIOD_FROM)+1) AS NRP_PD


Otherwise the +1 is not added to the interval value and is added after the division instead.


What you had was:

-12855.72/305+1 = -41.15

upaliwije
Creator II
Creator II
Author

Thanks

I completely missed it