Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to combine Three dates and three amounts

I am trying to calculate Gross Loss.  Gross Loss = Total Chargeoffs - (Total Restitution + Total Payments).  Each of these amounts is located in a different table with different date name, Charge off Month, Recovery Month and Payment Month.  I have loaded all of the appropriate tables into Qlikview and created a pivot for each piece of information.  I tried to create a pivot where my expression is Sum (ChargeOffAmount) - (Sum (RecoveryAmount) + Sum (PaymentAmount)), but because they use different date fields, the totals are incorrect. 

Any suggestions will be greatly appreciated.

1 Solution

Accepted Solutions
Not applicable
Author

can't you alias those 3 dates the same way?

or you can load all three tables into one table and add column like: type (where you put one of the string 'Charge', 'Recovery' and 'Payment' every row)

View solution in original post

10 Replies
Not applicable
Author

you should either convert dates from both tables in load script (better idea)

or

use calculated dimension

send the qvd or table files

Anonymous
Not applicable
Author

Hi PariPari,

By convert, do you mean, alias them to be the same?

Not applicable
Author

can you sand a sample of these tables (i am not sure i understand you - my eanglish is week )

Anonymous
Not applicable
Author

do I need to attach the qvw to my discussion or send the file to you directly?  i am very new to this forum.

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Its better to provide the structure of the tables to solve the problem which is helpfull to understand it easily

Celambarasan

Anonymous
Not applicable
Author

Understood..here are my load statements for the 3 tables in question...


CHARGEOFFS:

LOAD
CASEID,
CHARGEOFFAMOUNT,
    CHARGEOFFDATE,
    CHARGEOFFGL,
    CHARGEOFFSETRU,
    INCIDENTCOUNTERID,
    LOCATIONID,
    STARTDATE,
    CATEGORYID,
    Month(CHARGEOFFDATE) as ChargeOffMonth,
    Date(CHARGEOFFDATE,'MMM-YYYY') as ChargeOffMonthDate,
    Date (monthstart (CHARGEOFFDATE) , 'MMM_YYYY') as ChargeOffMonthYear;
SQL SELECT
CASEID,
CHARGEOFFAMOUNT,
    CHARGEOFFDATE,
    CHARGEOFFGL,
    CHARGEOFFSETRU,
    INCIDENTCOUNTERID,
    LOCATIONID,
    STARTDATE,
    CATEGORYID
FROM ICMSCITRIX.dbo.TBLINCIDENT
WHERE CHARGEOFFDATE >= '1/1/2012'
AND CHARGEOFFDATE <= '12/31/2012'
AND CHARGEOFFGL IN (860360, 980360, 990360, 970360, 860500);

RECOVERY:
LOAD CASEID,
    DATEOFRECOVERY,
    ITEMIZEDRECOVERYGL,
    ITEMIZEDRECOVERYLOSSLOCATION,
    TOTALRECOVERY,
    Month(DATEOFRECOVERY) as RecoveryMonth,
    Date (monthstart (DATEOFRECOVERY) , 'MMM_YYYY') as RecoveryMonthYear;
SQL SELECT CASEID,
    DATEOFRECOVERY,
    ITEMIZEDRECOVERYGL,
    ITEMIZEDRECOVERYLOSSLOCATION,
    TOTALRECOVERY
FROM ICMSCITRIX.dbo.TBLITEMIZEDRECOVERY
WHERE DATEOFRECOVERY >= '1/1/2012'
AND  DATEOFRECOVERY <= '06/28/2012'
AND  ITEMIZEDRECOVERYGL IN (860360, 980360, 990360, 970360, 860500);



PAYMENTS:

LOAD

CASEID,

INVESTIGATORID,

    PAYMENTAMOUNT,

    PAYMENTDATE,

    Month(PAYMENTDATE) as PaymentMonth,

    Date(PAYMENTDATE,'MMM-YYYY') as PaymentMonthDate,

    Date (monthstart (PAYMENTDATE) , 'MMM_YYYY') as PaymentMonthYear;

SQL SELECT

CASEID,

INVESTIGATORID,

    PAYMENTAMOUNT,

    PAYMENTDATE

FROM ICMSCITRIX.dbo.TBLRECOVERYPAYMENT

WHERE PAYMENTDATE >= '1/1/2012'

AND PAYMENTDATE <= '12/31/2012';

Not applicable
Author

can't you alias those 3 dates the same way?

or you can load all three tables into one table and add column like: type (where you put one of the string 'Charge', 'Recovery' and 'Payment' every row)

Anonymous
Not applicable
Author

I did that and it appears to be working, but now I have a synthetic key because MonthYear appears in 3 tables.

Not applicable
Author

it is a good practice to make a seperate table for calendar (move month, year, week....into it)