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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
fallenangel6
Creator
Creator

Best record( Best Column Value) Deducing to single record

 

Hi All,

I have data similar to the below table

clsidSourcepartyrkaccountrkpanPan Indicatorbankaccbank acc indicatormobilemobile indicator
1A211ABCXXAValid1223311Invalid123334544Valid
1A212AVDQWInvalid1556345Valid45568322Invalid
1A413QEEWRTInvalid NA25567788Invalid
1A414TEQTRRNA3776443Valid2112333Valid
1A415UEWIOPValid4.53E+07Invalid NA
1B316AAERDSSValidqq3eInvalid1666544Invalid
1B517 NA943321464Valid1566542Invalid
1B618QXCTDRInvalidq23wInvalid87642527Valid

 

My desired output is

clsidSourcepartyrkaccountrkpanPan Indicatorbankaccbank acc indicatormobilemobile indicator
1A415ABCXXAValid1556345Valid123334544Valid
1B618AAERDSSValid943321464Valid87642527Valid

 

for each combination of clsid and source, i need best indicator and best data.

For partyrk and accountrk, i take max(partyrk) and max(accountrk). 

Please help.

2 Replies
lanlizgu
Creator III
Creator III

Supposing that your first table is named Table1, let's try the following:

 

OutputTable:
LOAD
clsid,
Source,
max(partyrk) as partyrk,
max(accountrk) as accountrk
resident Table1
group by clsid, Source;


left join (OutputTable)
load
clsid,
Source,
partyrk,
accountrk,

pan,
[Pan Indicator],
bankacc,
[bank acc indicator],
mobile,
[mobile indicator]
resident Table1

drop Table1;

 

If you provide some sample data in a qvd I can give a try and just do it in one sentence without the left join.

 

Thank you.

lanlizgu
Creator III
Creator III

Based on your data you can use the following. My question is, what criteria are you using to obtain pan, pan indicator, bankacc, bank acc indicator, mobile and mobile indicator?

 

Table1:
LOAD * INLINE [
clsid, Source, partyrk, accountrk, pan, 'Pan Indicator', bankacc, 'bank acc indicator', mobile, 'mobile indicator'
1, A, 2, 11, ABCXXA, Valid, 1223311, Invalid, 123334544, Valid
1, A, 2, 12, AVDQW, Invalid, 1556345, Valid, 45568322, Invalid
1, A, 4, 13, QEEWRT, Invalid, , NA, 25567788, Invalid
1, A, 4, 14, TEQTRR, NA, 3776443, Valid, 2112333, Valid
1, A, 4, 15, UEWIOP, Valid, 4.53E+07, Invalid, , NA
1, B, 3, 16, AAERDSS, Valid, qq3e, Invalid, 1666544, Invalid
1, B, 5, 17, , NA, 943321464, Valid, 1566542, Invalid,
1, B, 6, 18, QXCTDR, Invalid, q23w, Invalid, 87642527, Valid
];

 

OutputTable:
LOAD
clsid,
Source,
max(partyrk) as partyrk,
max(accountrk) as accountrk
resident Table1
group by clsid, Source;


left join (OutputTable)
load
clsid,
Source,
partyrk,
accountrk,

pan,
[Pan Indicator],
bankacc,
[bank acc indicator],
mobile,
[mobile indicator]
resident Table1;

drop table Table1;