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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
KW123
Helper V
Helper V

Previous Month balance based on Closed Date

Hi, 

I have a list of customer ID's with closed accounts.  The data is organized by report month and I have columns with the customer ID, their account number, the account open date, the account closed date, and the current account balance (which is $0 because the account is closed) 

I need to find out what the account balance was the month prior to the account closing.  I am having a hard time finding the previous month that each customer closed their account because each row is a different date.  Additionally, the current balance is attached to the report month.  So if I filter the entire report by the report month, it will show the balances for that filtered month, not necessarily the closed month which is what I am looking for. 

Lets say the report is filtered by report month November.  This means that all current balances are 0.  
What I am looking to get

 Account NumberOpen Date Closed   DateCurrent balance
(Based on report Month)
What I am looking to get:
Previous Closed Month
What I am looking to get:
Previous Closed Month Balance
155502/03/2020 02/10/2022$0.0001/10/2022xxx
255610/09/2019 05/21/2021$0.0004/21/2021xxx
355703/20/2009 06/12/2020$0.0005/12/2020xxx
455803/25/2019 05/08/2022$0.00 04/08/2022xxx
555912/18/2020 08/09/2021$0.0007/09/2021xxx
656004/21/1995 06/04/2000$0.0005/04/2000xxx
756112/05/2001 07/08/2022$0.0006/08/2022xxx
856210/19/2020 02/09/2021$0.0001/09/2021xxx
956301/10/2000 03/04/2022$0.0002/04/2022xxx



6 REPLIES 6
amitchandak
Super User
Super User

@KW123 , Join both the dates with a date of a date table, Assume close date have inactive join

 

You need a measure like

calculate( calculate( SUM(Table[Amount]),USERELATIONSHIP ('Sales'[CreateDate], 'Date'[Date])),DATESMTD(dateadd('Date'[Date],-1,month)) )

 

calculate( calculate( SUM(Table[Amount]),USERELATIONSHIP ('Sales'[CreateDate], 'Date'[Date])),previousmonth('Date'[Date]))

 

Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s

 

Also check

openingbalancemonth, openingbalancequarter, openingbalanceyear: https://youtu.be/6lzYOXI5wfo
Power BI Allocating Targets- closingbalancemonth, closingbalancequarter, closingbalanceyear:https://youtu.be/yPQ9UV37LOU

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak Any suggestions? I am very stuck!

Anonymous
Not applicable

Hi @KW123 ,

 

If you want to get the Current balance for the month before the closed date, you can create a measure like the following shows:

last value = MAXX(FILTER(ALL('table'),eomonth('Table'[closed date],0)=EOMONTH(max('Table'[closed date]),-1)),'Table'[current value])

Then you can get the current value corresponding to the month on the closing date,Attached is a picture for your reference for comparison.

vmengzhumsft_0-1669197896749.png

 

You can also refer to my pbix file for better understanding.

 

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

@Anonymous 

 

Thank you for taking the time to reply! I tired the measure but it took a very long time to load and eventually there just wasn't enough memory to complete it. 

Looking at your example though, I am not sure that this is what I will need.  If we assume that the Sum of Index is a customer ID, it looks as though the DAX will return the previous value of a different customer ID.  

What I need to do is return the last value of the same customer ID.  In the Data set up screenshot I took, that is for one customer ID, not multiple.  In my report, I will have all customer ID. I hope that makes sense. 

Anonymous
Not applicable

Hi @KW123 ,

 

Can you show me the desired result you need, preferably in the form of a table expressing what you need to achieve, as my screenshot shows?

 

Best regards,

Community Support Team Selina zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @amitchandak 

Thanks so much for your reply.  I used the first DAX measure:

Measure 2 = calculate( calculate( SUM(Query1[CurrentBalance]),USERELATIONSHIP ('Query1'[ClosedDate], 'Dates'[Date])),DATESMTD(dateadd('Dates'[Date],-1,month)) )

And my column is giving me $0 for anyone with a closed date in October.  For everyone else, it's giving me blanks. 

I think the reason why is that the current balance is based on the report month which is currently set to November.  What I need to do is get the Current balance for the month before the closed date. 

Here is how the data is set up:

Report month.png

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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