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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors