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
VV24
Helper III
Helper III

calculate balance from month before min selected month

Dear all,

 

I would like to calculate the sum of my balance from the previous month.

 

So when i select january i want the sum of december. 

when i select january and february, i want to to sum december.

 

when i select february and march, i want the sum of january. and so on.

 

something like: calculate (sum(table1[value]);min(date)-1month)

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar Table with a Date column and build a relationship from the Date column of Table1 to the Date column of the Calendar Table.  In the Calendar Table, write these calculated column formulas to extract the Year and Month

Year = Year(Calendar[Date])

Month = FORMAT(Calendar[Date],"mmmm")

Build slicers for Year and Month and select any one Year in the Year slicer.  Select one/multiple months in the Month slicer.  Write this measure

=CALCULATE(SUM(Table1[Value]),DATESBETWEEN(Calendar[Date],EDATE(MIN(Calendar[Date]),-1),MIN(Calendar[Date])-1))

Hope this helps.


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

Please try one of the following

last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date Filer],-1,MONTH)))



perious month = 
Var _end_date= minx(ALLSELECTED('Date'),ENDOFMONTH(dateadd('Date'[Date Filer],-1,MONTH)))
Var  _start_date =minx(ALLSELECTED('Date'),STARTOFMONTH(dateadd('Date'[Date Filer],-1,MONTH)))

Var _last_mtd_val= CALCULATE(sum(Sales[Sales Amount]),Sales[Sales Date] >= _start_date && (Sales[Sales Date]) <= _end_date)
return
_last_mtd_val

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

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.