Forum Discussion
CALCULATE measure for current month
Trying to calculate only the selected month outstanding invoices from an Invoice & Receipts table and the measure is not working as expected.
Selected date can be any date in previous months. If the selection is for the end of month of SEP 2023,
1. Current Month total need to consider all the invoices for SEP and receipts for the invoices for SEP only. Receipts for prior month invoices should not be considered.
Current Month = CALCULATE (
SUM ( InvTable[Value] ) + SUM ( RcptTable[Value] ),
FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
)
Balance for Customer should consider all invoices and receipts until the selected date
InvTable has all invoices and RcptTable contains receipts and any advance payments
Invoice Table
| Customer | Invoice | Invoice Date | Value |
| CUS1 | INV-L1 | 8/20/2023 | 100 |
| CUS1 | INV-L2 | 8/20/2023 | 150 |
| CUS1 | INV-1 | 9/1/2023 | 500 |
| CUS1 | INV-2 | 9/15/2023 | 1000 |
| CUS1 | INV-3 | 9/25/2023 | 2000 |
| CUS5 | INV-6 | 10/4/2023 | 1100 |
Receipts of all invoices and any advance payment
| Customer | Invoice | Rcpt Date | Value |
| CUS1 | INV-L1 | 9/5/2023 | -100 |
| CUS1 | INV-1 | 9/1/2023 | -200 |
| CUS1 | INV-1 | 9/29/2023 | -200 |
| CUS1 | INV-2 | 9/30/2023 | -1000 |
| CUS1 | INV-1 | 10/2/2023 | -50 |
| CUS2 | ADV-1 | 9/20/2023 | -250 |
Expected result for selected date of 09/30/2023 ( End of Month)
| Customer | Balance | Current Month |
| CUS1 | 2250 | 2000 |
| CUS2 | -250 |
PBIX attached. Please advice. https://drive.google.com/file/d/1CRXVBsOICBmQHhcg5q9WXRbeA3roKXiK/view?usp=sharing
5 Replies
- Ashish_Mathur
Super User
- AnonymousNot applicable
Sorry. That is not adding up for Current month total. That is the issue that i posted.
For Sep , there are 3 invoices that adds up to 3500 (500 + 1000 + 2000) and receipts for SEP invoices adds up to 1400 (200 + 200 + 1000 ) . Current month total should show as 2100 and not 2250.
- Ashish_Mathur
Super User
Nowhere in your original post have you shared that the answer should be 2,100. Anyways, the answer should not even be that - it should be 2,000 i.e. 3,500 - 1,500. The revised measure for this will be:
Current month total = SUM(Invoices[Value])+[Receipts]