Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, everyone.
I have a table such as this.
Client # | Invoice # | Invoice Total ($) | Invoice Amount Paid ($) |
---|---|---|---|
1 | 10 | 100 | 40 |
1 | 10 | 100 | 50 |
1 | 11 | 200 | 100 |
1 | 11 | 200 | 30 |
1 | 12 | 300 | 150 |
2 | 13 | 900 | 250 |
2 | 13 | 900 | 220 |
2 | 14 | 800 | 460 |
And in QV, I have a Chart such as this, where I want to calculate the total pending amount:
Client | Total Pending Amount |
---|---|
1 | ? |
2 | ? |
That is, I want to take each Invoice Total for different Invoices and subtract Invoice Amount Paid.
For instance, for client 1, it would be: Total Pending Amount = 100 (because of invoice 10) + 200 (because of invoice 11) + 300 (because of invoice 12) - 40 - 50 - 100 - 30 - 150 (because of what has been paid for every invoice) = 230.
Could anyone help me please to achieve a expression for Total Pending Amount?
Thanks for reading.
Here it is:
Tab1:
Load * Inline [
Client #, Invoice #, Invoice Total ($), Invoice Amount Paid ($)
1, 10, 100, 40
1, 10, 100, 50
1, 11, 200, 100
1, 11, 200, 30
1, 12, 300, 150
2, 13, 900, 250
2, 13, 900, 220
2, 14, 800, 460
];
Tab2:
NoConcatenate
LOAD [Client #], Sum([Invoice Total ($)] - [Invoice Amount Paid ($)]) as InvPending Resident Tab1 Group By [Client #];
DROP Table Tab1;
Let me know
Alessandro, thanks for your answer.
Unfortunately, it's not what I'm looking for.
First, because I actually want a set analysis expression to do so, but more importantly, because you are repeating the invoice total for every invoice.
For instance, for invoice 10, my total is 100 - 40 - 50 = 10, and not 100 + 100 - 40 - 50. The invoice total for invoice 10 is 100, and not 200.
Thanks anyway for your answer.
Hi Sandeep.trs -
As I told Alessandro, the main problem here is that I have several rows for the same invoice. In your attached example (which I appreciate) no invoices are repeated, so the sum is pretty straightforward.
If you can, look at my example, which has a valid scenario (with repeated invoices). As I told Alessandro:
"For instance, for invoice 10, my total is 100 - 40 - 50 = 10, and not 100 + 100 - 40 - 50. The invoice total for invoice 10 is 100, and not 200."
Thanks!
Use this expression then
Sum(Aggr(sum(DISTINCT [Invoice Total ($)]),[Client #],[Invoice #]))-Sum(aggr(Sum([Invoice Amount Paid ($)]),[Invoice #],[Client #]))
sum(aggr(sum(DISTINCT [Invoice Total ($)]), [Client #], [Invoice #])) - sum([Invoice Amount Paid ($)])
Hi,
Same results by - Sum(DISTINCT [Invoice Total($)])-Sum([Invoice Amount Paid($)]) and Client# as the Dimension in Straight table chart