Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Pbi07
Helper V
Helper V

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 

2. Balance =
CALCULATE (
    SUM ( InvTable[Value] ) + SUM ( RcptTable[Value] ),
    FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] <= MAX ( 'Calendar'[Date] ) )
)

 

InvTable has all invoices and RcptTable contains receipts and any advance payments 

 

Invoice Table 

CustomerInvoiceInvoice DateValue
CUS1INV-L18/20/2023100
CUS1INV-L28/20/2023150
CUS1INV-19/1/2023500
CUS1INV-29/15/20231000
CUS1INV-39/25/20232000
CUS5INV-610/4/20231100

 

 

Receipts of all invoices and any advance payment 

CustomerInvoiceRcpt DateValue
CUS1INV-L19/5/2023-100
CUS1INV-19/1/2023-200
CUS1INV-19/29/2023-200
CUS1INV-29/30/2023-1000
CUS1INV-110/2/2023-50
CUS2ADV-19/20/2023-250

Expected result  for selected date of 09/30/2023 ( End of Month) 

 

 

CustomerBalanceCurrent Month 
CUS122502000
CUS2-250 
 


PBIX attached.  Please advice.   https://drive.google.com/file/d/1CRXVBsOICBmQHhcg5q9WXRbeA3roKXiK/view?usp=sharing

 

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Your answer of Balance seems wrong.  PBI file attached.

Hope this helps.

Ashish_Mathur_0-1701572892043.png

 

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

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. 

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]

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Sorry @Ashish_Mathur .  I think i didn't make it clear in my earlier post. 

Current Balance is actually the invoices that is balance for the month selected. So if there is a receipt for an invoice from previous month that should NOT be in the current month balance. 

In the example i shared, only INV-1 & INV-2 are the invoices paid to be accounted for receipts.  That's why receipts is 1400. 

Pbi07_0-1701649135944.png

 

 

 

 

I just cannot understand your question.  Someone who does will help you.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.