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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Time Intelligence - Create a Variable to return Previous Month for Custom Calender

Hello, I have a custom Calender where May is termed as BinderMonth1 and April is the 12th Month of the Binder Year. I need to create a variable to return previous month. But If the Month in Context is May then it should return April of Last year as Previous Month. How can i do that? The code in work is:

VAR PreviousPolicyMonth =
IF(
HASONEVALUE(DimDate[BinderMonthNumber]),
IF(CurrentPolicyMonth =1,TOTALMTD(PREVIOUSMONTH(DimDate[BinderMonthNumber]),ALL(DimDate), DimDate[BinderMonthNumber] = MaxMonthNumber && DimDate[Binder Year] = CurrentYear -1), VALUES(DimDate[BinderMonthNumber])-1)
,BLANK()
)
I am struggling with the third line on this code where i need to add previous month dynamic for May to return April of last year as mentioned above. Kindly help. Thank you. @amitchandak @Anonymous @harshnathani 
1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , You can use Rank for that. As long as you have a start date, you can create rank on that and use that to find this period vs last period

 

refer to the week example. same is true for any custom period

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors