Pregunta

I have three to more vendor one can be paid and others may not be paid. so if the vendor is paid he will check a check box(X) near to the amount box. The check box datatype is text. i want to put a calculation that should exclude the vendor paid and should calculate the remaining amount. This is how i implemented.

If(
   (IsEmpty ( Vendor Paid )); 0;
   Sum(Invoices::Cost Total)
)

Here the Vendor Paid is the column name and Cost Total is the sum of all the vendors including the paid one.

Cost Total=  Sum ( Invoice Line Items::Actual_Extended Cost )
¿Fue útil?

Solución

If I am understanding your database structure properly, you have three tables Vendors, Invoices and Invoice Line Items. Your Invoice Line Items table has a field Cost on it. Your Invoices table has a flag (field) Vendor Paid on it. And on the Vendors table you'd like a sum of the total cost and a sum of the unpaid cost.

These fields are related in one-to-many relationships as follows:

Vendors --< Invoices --< Invoice Line Items

Here's one method:


Invoices Table

On your Invoices table create a calculation field Invoice Total, which is the sum of all costs. The code for which is:

Sum ( Invoice Line Items::Cost )

Additionally on your Invoices table create a calculation field Invoice Total Unpaid, which is the cost if your Vendor Paid field is not checked:

If (
    IsEmpty ( Vendor Paid ) ; 0 ;
    Invoice Total
)


Vendors Table

Now on your Vendors table you can create your Cost Total calculation field, the sum of all costs:

Sum ( Invoices::Invoice Total )

And a Cost Total Unpaid calculation field, the sum of all unpaid costs:

Sum ( Invoices::Invoice Total Unpaid )
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top