Lookup SQL SELECT Statement in a Container

Hello!

We have an A/R Aging report in Sage intelligence reporting and now I'm trying to add the MemoText in the AR_InvoiceHistoryMemo table where MemoCode = "COLLECTION".

Below are my statements, but the report still doesn't only pull the MemoText where MemoCode = 'COLLECTION'. Can you please help and let me know what I got wrong with the statements? Very appreciated!!

Expression Name:

MemoText_Collection

Expression Source:

 [AR_InvoiceHistoryMemo].[MemoText],[AR_InvoiceHistoryMemo].[MemoCode]

LookupSQL SELECT Statement:

SELECT DISTINCT [AR_InvoiceHistoryMemo].[MemoText], [AR_InvoiceHistoryMemo].[MemoCode] FROM [AR_InvoiceHistoryMemo] WHERE [AR_InvoiceHistoryMemo].[MemoCode] = "COLLECTION"

Thanks!!

Jun

Parents Reply
  • 0 in reply to Jun Zheng

    Create a new SQL Data Expression call it Collection and add it to the report Columns.

    Use the following SQL in the Expression Source:

    CASE

    WHEN AR_InvoiceHistoryMemo.MemoCode = 'COLLECTION' Then AR_InvoiceHistoryMemo.MemoText

    ELSE

    ' '

    END

    The field will display the Memo Text for the Collection records and blank for everything else.

Children
  • 0 in reply to Doc102208

    Hey! I'm still struggling with the same issue after three years, LOL, but I can clarify this. One invoice number could have multiple memo codes, and I want to add the memo text when the memo code = 'COLLECTION' only. Otherwise, different codes will duplicate rows/invoices in the report. Will your "case when" method still duplicate rows when there is more than one memo code? Thanks!