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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
43918084
Creator II
Creator II

Count Total occurance in 2 concatenated tables

 I need to concatenate below Table 1 and Table 2, then add calculated field "Total TradeID", and "Status"

But I keep getting 'Invalid expression' Error.  Hope I can get some help.

Table1&2temp:

Load

Date(Date#([Reportdate], 'YYYYMMDD') ) AS [Reportdate],
 [TradeID],
 Date(Date#([MatDate], 'YYYYMMDD') ) AS [MatDate],
 Date(Date#([TradeDate], 'YYYYMMDD') ) AS [TradeDate],
 [Notional],
    Count(DISTINCT TradeID) As Total_TradeID 
 RESIDENT [Table1&2] Group by Period, Reportdate, MatDate,TradeDate;
DROP TABLE [Table1&2]; 

 

Table1       
Report dateTradeIDMatDateTradeDateNotional Total TradeIDStatus
20191231ex12020123020181030100 4Exist
20191231ex12020123020181030100 4Exist
20191231mat1201912302018103010 1matured
20191231Term120201230201810301 1Exist
Table2       
Report dateTradeIDMatDateTradeDateNotional   
20200131new1202012302020010150 1Exist
20200131new220201230202001012 1Exist
20200131ex12020123020181030100 4Exist
20200131ex12020123020181030100 4Exist
2 Replies
Vegar
MVP
MVP

Table1&2temp:

Load

Date(Date#([Reportdate], 'YYYYMMDD') ) AS [Reportdate],
 [TradeID],
 Date(Date#([MatDate], 'YYYYMMDD') ) AS [MatDate],
 Date(Date#([TradeDate], 'YYYYMMDD') ) AS [TradeDate],
 [Notional]

 RESIDENT [Table1&2]; 

Left join Load TradeID, 

Count(TradeID) as TotalNoOfTradeIDs

Resident [Table1&2]

Group by TradeID; 

Drop table  [Table1&2];

43918084
Creator II
Creator II
Author

Thank you so much.  This solution really helps. 

Sorry, I have one more question relating to the Status field.  The status field is a calculated field based on the

Field TotalNoOfTradeIDs.  I need to build formula like  " If( TotlaNoOfTradeIDs = 1 and MatDate >Reportdate, 'Exist', 'Mature).

 

May I know how I can add the 'STatus' field into the Table1&2?  Many thanks again