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

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
LoKi_asterix
Contributor III
Contributor III

First values with conditions

Hey folks, I’m dealing with a transactional table where the first entries are the initial investments, and the rest may be other types of transactions. But with the transaction codes 'TC00402' quite narrows it.

I want to pull out just those initial investments by looking at the earliest date for each account. Some accounts only have one record, while others have multiple entries on the same date.

How would you go about separating these in the script? Would love any tips or approaches!

Labels (4)
3 Replies
PrashantSangle

can you provide some sample data with expected o/p??

 

regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
LoKi_asterix
Contributor III
Contributor III
Author

@PrashantSangle 

CusIDTransCodeDate Amount
aaa13601/01/24100
aaa13601/05/2550
aaa42006/09/25100
bbb6101/01/25120
ccc6101/05/2375
zzz13601/01/23500
zzz6102/09/2515
ddd42002/02/2510
ddd42002/02/2520
ddd42002/02/2520
ddd42009/09/2540
eee42007/09/255
eee42008/10/255
eee42008/11/255

This is how the results are supposed to work based on the business rules.

For CustID aaa, transaction code 136 is the correct one to use. So the principal is 100 + 50 = 150.
Code 420 is ignored because it represents an incorrect narration in this case.

For CustID bbb and CustID ccc, code 61 is the valid transaction type, giving principals of 120 and 75 respectively.

CustID zzz has two valid transaction types: 136 (cash deposit) and 62 (transfer). Since both are legitimate, both amounts are included, giving a total of 515.

Code 420 usually represents balance brought forward and can appear multiple times.
When all 420 entries for a customer fall on the same date, their amounts should be added together.
That’s why CustID ddd ends up with 10 + 20 + 20 = 50.

For CustID eee, code 420 appears on different dates, so only the first occurrence is taken and the rest are ignored.

hanna_choi
Partner - Creator II
Partner - Creator II

Hello @LoKi_asterix 

How about this ways?

After extracting MIN values by CUSID and YEAR
Sum the corresponding Amount for the Min value

We got the desired value.


hanna_choi_0-1765762710524.png


[ Load Script ]

hanna_choi_1-1765762889159.png