jrRaid Posted March 25, 2008 Posted March 25, 2008 I have a table with invoices and a field with the outstanding balance for each invoice. I need a field (calculation) a sort of 'customerflag', when the balance on 3 successive invoices of a given customer exceeds a given amount. I found a way to have it with a script (search/found set/loop/flag), but I wonder if there is a way without user interaction (no button click to activate script) TIA
BobWeaver Posted March 26, 2008 Posted March 26, 2008 Assuming you have the following fields: CustomerID - A unique field identifying the customer InvoiceNumber - A unique field identifying the invoice in sequential order (ie, a serial number of some sort) InvoiceAmount - The total amount of the invoice Create a selfjoin relationship called "AdjacentInvoices" with the following two parameters: CustomerID = CustomerID InvoiceNumber <= InvoiceNumber Have the relationship sort by InvoiceNumber (descending). Then you can create a new CustomerFlag calculated field with this formula: Let([ n=Count(AdjacentInvoices::CustomerID); Amount2=GetNthRecord ( AdjacentInvoices::InvoiceAmount ; 2 ); Amount3=GetNthRecord ( AdjacentInvoices::InvoiceAmount ; 3 ); TotalAmount=Case(n<3;0;InvoiceAmount+Amount2+Amount3) ]; Case(TotalAmount>500;"Warning";"") )
Recommended Posts
This topic is 6145 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now