We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to calculate outstanding invoices before the creation date of a new invoice

PaolaHL
5 - Atom

I’m working on a workflow and need to calculate the number of outstanding invoices prior to the creation date of a new invoice for each customer. Specifically, I want to compare the creation date of the current invoice to the payment dates of all previous invoices for the same customer. If the creation date is before the payment date of any previous invoice, it should be counted as outstanding.

For example, given the following data, I'd like to obtain the last column in the table below:

Customer IDInvoice IDInvoice creationPayment dateOutstandingInvoices
112024-01-282024-02-09null
122024-01-302024-02-101
132024-02-162024-05-050
142024-03-092024-05-101
152024-04-302024-05-022
162024-05-062024-05-301

 

For invoice 1, there are no previous invoices, so the outstanding count is null. For invoice 2, it was created before the payment of invoice 1, so the count is 1. For invoice 3, it was created after the payment of invoices 1 and 2, so the count is 0, and so on.

How can I achieve this in Alteryx? My first approach was to use a multi-row formula tool, but I would like to have more flexibility on the number of rows that will be used for the calculation, as they vary depending on the number of invoices issue to different customers.

2 REPLIES 2
OTrieger
14 - Magnetar

@PaolaHL 
You can use Summarize Tool, by grouping on invoice and then count by invoice. Getting one you know that it appears only one time, if bigger than one then you know that it is in multiple rows.

Join then Count number to the data and then with a formula tool with an IF function you can get what you want.

CoG
14 - Magnetar

Here is an approach that first Joins on Customer ID, and Filters down only outstanding invoices, Union to account for 0 outstanding invoices, followed by Summarize and Formula Tool to get the actual value:

Screenshot.png

Labels
Top Solution Authors