Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
phillipmacd
Contributor III
Contributor III

Help with Peek() and comparing 2 values

Hi all.

Hope someone could direct me in the right direction on solving my problem.

I need to flag records in a table on matching criteria. I think the best way is going to have to use the peek() function.

I have a few dimension containing transaction data. I need to check for matching doc numbers and where they are found check the customer linked to the document.

example of data:

DATEDOC_NOCUSTOMER#FLAG
2018-01-01123AOK
2018-01-01123A
2018-01-01124BFAIL
2018-01-01124C

if the document numbers match and the customer is a match for that document number it should be flagged as "OK", but where

the document numbers match and the customer differs it needs to be flagged as "FAIL"

I can find the matching DOC_NO, but i have no idea how to check the CUSTOMER when it is found, any ideas??

Thank you in advance....

20 Replies
phillipmacd
Contributor III
Contributor III
Author

Hi Kushal, attached is an example of my data, i know its only a few records ( current data is about 6 million records)

so its difficult to check by hand.

the sample data shows how the transactions work, for each DOC_NO there are 2 or more records for both debit and credit transactions( depending on the amount of debits or credits). These should always sum to 0(zero) on the CUSTOMER 's account. I need to test weather the transactions for debit and credit are only on 1(one) CUSTOMER per DOC_NO.

So I need to match DOC_NO in records and when a match is found I need to test the CUSTOMER and verify that it is the same CUSTOMER for both the debit and credit for the DOC_NO.

Hope this help explain the data

vishsaggi
Champion III
Champion III

Hey Philip

DId you try what Tamil suggested? If not try that it will solve your issue.

Thanks,
V.

Anonymous
Not applicable

Something like this

Temp1.jpg

phillipmacd
Contributor III
Contributor III
Author

Hi V, I am busy testing the result, just need to check if all is ok.

phillipmacd
Contributor III
Contributor III
Author

Hi Kushal, that is exactly what i am looking to do

balabhaskarqlik

May be this:

If(DOC_NO = Peek(DOC_NO) and CUSTOMER = Peek(CUSTOMER),'OK','FAIL') as Flag;

Checking the flag on both doc_no and customer details.

phillipmacd
Contributor III
Contributor III
Author

Hi Bala

NO success. flags the one side of the DOC_NO (debit or credit) as 'OK' and the other (credit or debit) as 'FAIL'

phillipmacd
Contributor III
Contributor III
Author

Hi All, at this stage i am stuck, i am going to rather check when the amount (both debit and credit) of the DOC_NO does not sum to zero(0).

This should give  a better view on the different CUSTOMERS linked to a DOC_NO.

Thank you all for the input.

Anonymous
Not applicable

Let me know if this works for you.

Temp:

LOAD DOC_NO,

     DATE,

     CUSTOMER,

     AMOUNT,

     DOC_NO & CUSTOMER as UJt,

     DOC_NO & CUSTOMER as UJ

FROM

(ooxml, embedded labels, table is Sheet3);

left join(Temp)

LOAD UJt as UJ,

if(SUM(AMOUNT)<>0,'Fail','Ok') as Flag

Resident Temp group by UJt;

phillipmacd
Contributor III
Contributor III
Author

Thank you Kushal, will do so.