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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
rocky84
Regular Visitor

Need help with Current Month and Prior Month

Hello,

Hoping some Power BI experts can help me with the following task, which is crucial for Financial analysis.

 

I have a set of financial information which I update monthly with a new batch of numbers.

 

I already have a date calendar query build in, but what I would like is a new column which will show "Current Month", "Prior Month" or "Other".

 

Current month should be the most recent but 1 month (i.e. if we are in February 2023, "Current Month" should be "January 2023").

Likewise, "Prior Month" should be "December 2022)

 

Am sure this has been asked before but I can't seem to apply any solutions to my challenge.

 

thanks in advance! 😀

2 REPLIES 2
amitchandak
Super User
Super User

@rocky84 , if you need based on today, assume no filter

 

use

 

This Month Today =
var _min = eomonth(today(),-2)+1
var _max = eomonth(today(),-1)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Last Month Today =
var _min = eomonth(today(),-3)+1
var _max = eomonth(today(),-2)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

or

 

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

 

Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
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

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thanks for the guidance (and apologies for my delayed response)

 

I think this would work for sure, but it doesn't look like it considers the year at all? Only the month?

 

So ideally it should say "ok today is 28 Feb 2023", therefore the current, most recent closed reporting month is "jan 2023". Also, the prior month, would be december 2022, so the formula should realise that this is 2022, not 2023. Does that makes sense?

 

thanks again for your valued insight! 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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