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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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

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

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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